If you have followed the steps in Getting Search Rules to work with normal (click) Category navigation to have search rules for category navigation, you may have an issue with the displayable flag not being considered when unset for a category in Management Center. For example, if you have a facet set as displayable, then for a particular category, you mark the facet as nondisplayable, it will still be displayed on the storefront. This is because we will not check the displayable flag set for a particular category, since we are not performing category navigation (due to hardcoded keyword search to enable original search rule customization).
To work around this issue, you will need to create a custom query preprocessor, which will check and remove the nondisplayable facets. Here is the logic needed for the custom query preprocessor:
- Get the list of facets being added into the Solr query (iSolrQuery.getFacetFields())
- Get the categoryId, search profile, and search index from the control parameters.
- Call FacetHelper.excludeNonDisplayableFacets(allFacetFields, astrCategory, astrSearchIndex, astrSearchProfile).
- Remove all the facets that aren't returned by excludeNonDisplayableFacets since it will only return the displayable facets.
Once you implement the custom query preprocessor, include the preprocessor in the search profile, restart the server, and verify that you can't see the undisplayable facets for the particular category.