1

I have 12 sales orders which have "store_id" = 1. Out of which 3 orders have "status" = "pending"

I get all the 12 orders when I make a GET request to http://mystore/index.php/rest/V1/orders?searchCriteria[filter_groups][0][filters][1][field]=store_id&searchCriteria[filter_groups][0][filters][1][value]=1

I want to make a OR search, I want all the orders for which "store_id" = 1 OR "status" = "pending" Ideally I should get all the 12 orders, but my following request gets back only 3 orders in response: http://mystore/index.php/rest/V1/orders?searchCriteria[filter_groups][0][filters][1][field]=store_id&searchCriteria[filter_groups][0][filters][1][value]=1&searchCriteria[filter_groups][0][filters][1][field]=status&searchCriteria[filter_groups][0][filters][1][value]=pending

I had the knowledge that different filters inside a filter group are merged the OR way. And the filter groups are merged the AND way.

But this is not working.

Even the following request gets 3 orders: searchCriteria[filter_groups][0][filters][0][field]=store_id&searchCriteria[filter_groups][0][filters][0][value]=1&searchCriteria[filter_groups][1][filters][0][field]=status&searchCriteria[filter_groups][1][filters][0][value]=pending

Both filter_groups and filters are being merged the AND way.

Please help.

Assumptions: There are no syntax mistakes in making the request.

1

1 Answer 1

1

have you tried to set different indexes for filters. The first should be with [filters][0], and the second - [filters][1]?

http://mystore/index.php/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=store_id&searchCriteria[filter_groups][0][filters][0][value]=1&searchCriteria[filter_groups][0][filters][1][field]=status&searchCriteria[filter_groups][0][filters][1][value]=pending

In your case, you use just [filters][1], and you get only condition "status=pending"

Your Answer

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

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