Reputation: 97
I am working on magento 2 api. I need products based on below filters
I have try with this api but no option available
index.php/rest/V1/categories/{id}/products
Please someone suggest how to archive this.
Thanks
Upvotes: 2
Views: 7005
Reputation: 433
[
"filter_groups": [
{
"filters": [
{
"field": "type_id",
"value": "simple",
"condition_type": "eq"
}
]
},
{
"filters": [
{
"field": "category_id",
"value": "611",
"condition_type": "eq"
}
]
}
],
"page_size": 100,
"current_page": 1,
"sort_orders": [
{
"field": "name",
"direction": "ASC"
}
]
]
Upvotes: -2
Reputation: 1397
You are looking for the (GET) API /rest/V1/products
.
test
, the API will start with GET /rest/test/V1/products/[...]
.like
condition type. Ex.: products with "sample" in their name: ?searchCriteria[filter_groups][0][filters][0][field]=name
&searchCriteria[filter_groups][0][filters][0][value]=%sample%
&searchCriteria[filter_groups][0][filters][0][condition_type]=like
sortOrders
. Ex.: searchCriteria[sortOrders][0][field]=name
. You can even add the sort direction, for example DESC, with searchCriteria[sortOrders][0][direction]=DESC
.category_id
field and the eq
condition type. Ex.: if you want products from category 10: searchCriteria[filter_groups][0][filters][0][field]=category_id&
searchCriteria[filter_groups][0][filters][0][value]=10&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq
searchCriteria[pageSize]
. Ex.: 20 products starting from the 40th, equivalent in SQL to LIMIT 20 OFFSET 40
: &searchCriteria[pageSize]=20&searchCriteria[currentPage]=3
Of course you can perform AND and OR operations with filters.
Upvotes: 6