I tried to get full list of order item attributes by this url: api/rest/orders/25/items . There are:
"item_id": "62",
"parent_item_id": null,
"product_type": "simple",
"sku": "89110065",
"name": "Diamond Glow Nourishing Mud Mask",
"qty_canceled": "0.0000",
"qty_invoiced": "0.0000",
"qty_ordered": "1.0000",
"qty_refunded": "0.0000",
"qty_shipped": "0.0000",
"price": "277.3100",
"base_price": "277.3100",
"original_price": "330.0000",
"base_original_price": "330.0000",
"tax_percent": "19.0000",
"tax_amount": "52.6900",
"base_tax_amount": "52.6900",
"discount_amount": "0.0000",
"base_discount_amount": "0.0000",
"row_total": "277.3100",
"base_row_total": "277.3100",
"price_incl_tax": "330.0000",
"base_price_incl_tax": "330.0000",
"row_total_incl_tax": "330.0000",
"base_row_total_incl_tax": "330.0000"
If you look at the order item object, you will see that it has more attributes. Is it possible to add a custom attribute to this list? Or I have to overwrite the existing API to add a custom attribute?
Best Answer
The attributes you see there are defined in
api2.xml
file of the sales module.Here they are
This
api2.xml
works like any other XML in magento. It is merged with all the otherapi2.xml
files in all the modules.So In order to add your own attributes you can create your own module that contains the file
etc/api2.xml
where you can add your attributes, but keep the tag structure.Your
etc/api2.xml
could look like this.Clear the cache when you are done.
You may need to give access to the new attributes in the api user roles section, but not sure.