0

I'm having a really hard time to retrieve orders by entity_id. I'm calling '/rest/V1/orders' and passing this parameters:

{
  'searchCriteria[filter_groups][0][filters][0][field]': 'entity_id',
  'searchCriteria[filter_groups][0][filters][0][value]': '1',
  'searchCriteria[filter_groups][0][filters][0][condition_type]': 'eq',
  'searchCriteria[filter_groups][0][filters][1][field]': 'entity_id',
  'searchCriteria[filter_groups][0][filters][1][value]': '2',
  'searchCriteria[filter_groups][0][filters][1][condition_type]': 'eq',
  'searchCriteria[current_page]': 1,
  'searchCriteria[page_size]': 100
}

When trying to do that it results with an empty array. Using only one filters returns a proper order. I also tried using "in" filter

{
  'searchCriteria[filter_groups][0][filters][0][field]': 'entity_id',
  'searchCriteria[filter_groups][0][filters][0][value]': '1,2',
  'searchCriteria[filter_groups][0][filters][0][condition_type]': 'in'
  'searchCriteria[current_page]': 1,
  'searchCriteria[page_size]': 100
}

Passing params like this result in returning order with ID 1, but no order with ID 2. If I change the order of filter value to '2,1' it returns only order with ID 2.

What am I doing wrong here ? What is the proper way of getting orders from REST API by their IDs ?

0

The syntax should be like that:

{
  'searchCriteria[filter_groups][0][filters][0][field]': 'entity_id',
  'searchCriteria[filter_groups][0][filters][0][value]': '1, 2',
  'searchCriteria[filter_groups][0][filters][0][condition_type]': 'in'
}

but seems, there are bugs.

https://github.com/magento/magento2/issues/2892

https://github.com/magento/magento2/issues/3411

and

https://github.com/magento/magento2/issues/3018

0

Here is the bugfix while the next release is not out:

https://github.com/magento/magento2/commit/65819d2f61a63e4fa9fc978220f8662ee5472791

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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