Sometimes you have items that you want to hide on particular stores/pages of your Magento site in the Algolia Search Results.
You can achieve this by adding a filter that will hide the items that you do not want to show.
Enable filtering with the attribute
In order to be able to use an attribute for filtering, you will first need to make the attribute a facet in your Magento back end: https://www.algolia.com/doc/integration/magento-2/how-it-works/indexing/?client=php#facets
And then, remove or edit this facet in your front end with the beforeWidgetInitialization hook to remove the facet that is created for this filter from your front end so that it matches your design: https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events/?client=php
Making the filter
Then you can add such a filter in the front end using the configure widget. Here is a working CodeSandbox example showing how to add a filter with this widget: https://codesandbox.io/s/add-a-filter-with-the-configure-widget-9scg4
Here is the filter:
// We will only see results with free shipping
instantsearch.widgets.configure({ filters: 'free_shipping:true', }),
You can add this to your Magento site with the beforeWidgetInitialization hook which is documented here: https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events/?client=php#instant-search-page-events
Please note that this filter will be on your front end and so should not be used for hiding records you need to keep secret for security reasons.
Last reviewed 29-04-22.