0

How can we retrieve the filter options in a category with REST API?

In the product category page, I have the filters as below and it depends on each category.

  • Product Category Filter
  • Filter by stock
  • Filter by on stock
  • Filter by price
  • Filter by Manufacturer

etc......

So I just want to retrieve this values in REST API. How can we achieve this?

  • Have you tried search criteria ? – Aditya Shah Oct 30 '18 at 9:13
  • @AdityaShah Actually, I just want to list all the available filters for the particular category. I'm not aware of the search criteria. If you can point out that would be better. Thanks – Shafeeque S Oct 30 '18 at 9:15
  • I added an answer – Aditya Shah Oct 30 '18 at 9:35
  • @AdityaShah updated the Qn. – Shafeeque S Oct 30 '18 at 9:58
  • Well,I have provided a link. – Aditya Shah Oct 30 '18 at 10:18
0

How can we retrieve the filter options in a category with REST API?

GET    /V1/categories/:categoryId/products

Now, apply searchCriteria

The searchCriteria query parameter allows you to search across multiple objects in a collection. You can use the fields query parameter in conjunction with searchCriteria to limit the output. The question mark (?) that precedes fields in all the other examples in this document is replaced with an ampersand (&).

The following query returns only the sku and name parameters for product items whose category_gear attribute includes the value 86.

GET http://<host>/rest/V1/products/?searchCriteria[filter_groups][0][filters][0][field]=category_gear&searchCriteria[filter_groups][0][filters][0][value]=86&searchCriteria[filter_groups][0][filters][0][condition_type]=finset&fields=items[sku,name]

example

GET http://<magento_host>/rest/V1/products?
searchCriteria[filter_groups][0][filters][0][field]=sku&
searchCriteria[filter_groups][0][filters][0][value]=WSH%2529%25&
searchCriteria[filter_groups][0][filters][0][condition_type]=like&
searchCriteria[filter_groups][0][filters][1][field]=sku&
searchCriteria[filter_groups][0][filters][1][value]=WP%2529%25&
searchCriteria[filter_groups][0][filters][1][condition_type]=like&
searchCriteria[filter_groups][1][filters][0][field]=price&
searchCriteria[filter_groups][1][filters][0][value]=40&
searchCriteria[filter_groups][1][filters][0][condition_type]=from&
searchCriteria[filter_groups][2][filters][0][field]=price&
searchCriteria[filter_groups][2][filters][0][value]=49.99&
searchCriteria[filter_groups][2][filters][0][condition_type]=to
  • 1
    LOL someone just down voted the answer :D Whoever did this - buddy if you have the query then simply just ask ! – Aditya Shah Mar 22 at 6:29

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.