1

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?

6
  • Have you tried search criteria ? Commented Oct 30, 2018 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 Commented Oct 30, 2018 at 9:15
  • I added an answer Commented Oct 30, 2018 at 9:35
  • @AdityaShah updated the Qn. Commented Oct 30, 2018 at 9:58
  • Well,I have provided a link. Commented Oct 30, 2018 at 10:18

1 Answer 1

-1

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
3
  • 1
    I think the question is to get the available filters for a particular category. Commented Nov 20, 2019 at 13:19
  • Yes @Mohitchauhan We can achieve this by above :) for particular category you need to pass specific ID in here -> /V1/categories/:categoryId Commented Nov 20, 2019 at 14:34
  • Question is for available layer navigation filter by current category/current id Not search by category Commented Jun 12, 2020 at 10:26

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.