I would like to filter out all orders with a specific country_id
.
Here a sample from the json
response:
{
"items": [{
"total_qty_ordered": 3,
"updated_at": "2018-01-10 15:59:05",
"weight": 0,
"billing_address": {
"city": "Schaffhausen",
"country_id": "CH"
}
}]
}
Here is what I’ve tried:
url = (
"http://<host>/rest/V1/orders"
"?searchCriteria[filter_groups][0][filters][0][field]=country_id"
"&searchCriteria[filter_groups][0][filters][0][value]=CH"
)
It’s not working because country_id
is in a nested entity.
So I’ve tried to replace country_id
by billing_address[country_id]
but it’s not working either.
2
Answers
This is the json structure for the search criteria..
The default REST API for search is only searching for the column which is available in
sales_order
table.You can not search with
country_id
, you will get an error like column not found. To make it work you have to customize the methodgetList
magento/module-sales/Model/OrderRepository.php
by creating custom module OR you can build your custom API to fetch order details based oncountry_id
The proper URL
Method:
GET
Header :