Exclude Categories from Search Results
By default, all categories indexed to Klevu have a visibility of search. There are 2 possible approaches to change this depending on your needs. The first is to exclude the category from the sync altogether using an isIndexableCondition. The second is to change the visibility sent in the data.
Excluding the category this way would result in no products showing for this category on the frontend of your store for Category Navigation.
To do this we inject an isIndexableCondition into the isIndexableConditions array for the virtual type Klevu\IndexingCategories\Service\Determiner\IsIndexableDeterminer
Create that class, which must implement the IsIndexableConditionInterface
See Entities Is Indexable Determiner for more information.
To change the data synced we must override the pipeline YAML for categories.
Create the override YAML file
Create the imported visibility YAML file. It is possible to do this all in one YAML file, but separating it into multiple files makes it easier to read. To remove all categories from search.
To remove some categories from search. Take the current category and pass it into a transformer. This transformer should return an array of strings containing with or search.
Create the transformer to handle the visibility
If you create a transformer in a custom module it must be registered with the pipelines before it can be used. See Registering Transformers for more information.
Alternatively we could add an attribute to the category for visibility and use that instead of a transformer. e.g.
Assumes getVisibility would return either or search. If it returned an integer then we'd have to map that. see the visibility YAML for products module-m2-indexing-products/etc/pipeline/product/attributes/visibility.yml
See Pipeline Customisation for more information on how to customise pipelines.