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.

Alex Paliarush
13.8k5 gold badges53 silver badges57 bronze badges
asked Nov 23, 2015 at 14:24
1
  • I tried to check the code, but i lost :( Somebody can help me? Commented 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
answered Nov 25, 2015 at 9:33
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.