6

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.

1
  • I tried to check the code, but i lost :( Somebody can help me?
    – chrispooh
    Nov 24, 2015 at 10:37

1 Answer 1

5

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:

  1. Get list of order IDs which you are interested in (e.g. using request provided in the question)
  2. To get product details use \Magento\Sales\Api\OrderItemRepositoryInterface::getList($searchCriteria). Via REST it is available as GET <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
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.