I am creating a custom API endpoint for returning the filters for a particular search term. I tried following the “Magento GraphQL’s approach” and used
MagentoCatalogGraphQlModelResolverLayerFiltersProvider::getFilters(MagentoCatalogModelLayerResolver::CATALOG_LAYER_SEARCH)
but the problem is that it is returning ALL the filters with all their options instead of only the ones with products in them. For example, if I search for iphone
and the possible values of the filter RAM
are 4gb
, and 6gb
. But if I use this technique it’s returning the other filter values as well, like 8gb
, 10gb
etc., clicking on which is returning 0 products.
This is not how it is working in LUMA. So my guess is that I’m doing something wrong.
So what I’m asking I guess is, how to return the proper filters array for a search term programmatically