I would like to have the proper cURL command for getting all pending orders with the products' custom attributes in Magento 2 REST API. I use this, but there are no custom attributes on the products in the result.
curl -X GET -H "Authorization: Bearer xxxxxxxxxxxxxxxxxxxx" -H "Cache-Control: no-cache" 'http://xxxxxx.xxx/index.php/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=status&searchCriteria[filter_groups][0][filters][0][value]=pending'
What am I doing wrong? I get everything but not the product attributes and the custom product attributes.
-
I tried to check the code, but i lost :( Somebody can help me?chrispooh– chrispooh2015年11月24日 10:37:37 +00:00Commented Nov 24, 2015 at 10:37
1 Answer 1
One order can contain multiple products, which are represented as order items in the context of order. With order APIs you cannot get order list with order items in one request. But it can be done as follows:
- Get list of order IDs which you are interested in (e.g. using request provided in the question)
- To get product details use
\Magento\Sales\Api\OrderItemRepositoryInterface::getList($searchCriteria). Via REST it is available asGET <base_url>/V1/orders/items. Iterate through orders from the previous step and for each one get its items, in search criteria specify filter by order ID
Explore related questions
See similar questions with these tags.