Indexing
...
Entities
Discovery
Is Indexable Determiner
3min
determiners & conditions if an entity is indexable is determined by klevu\indexing\service\determiner\isindexabledeterminer this determiner loops through all injected klevu\indexingapi\service\determiner\isindexableconditioninterface classes if any of these return false; then the entity is set to not indexable and will not be indexed with klevu if they all return true; then the entity is indexable and can be indexed with klevu all entity types module ms indexing categories , module ms indexing cms and module m2 indexing products create virtualtypes of this class and inject an array of conditions e g for products the virtualtype in di xml looks like this module m2 indexing products/etc/di xml \<virtualtype name="klevu\indexingproducts\service\determiner\isindexabledeterminer" type="klevu\indexing\service\determiner\isindexabledeterminer"> \<arguments> \<argument name="isindexableconditions" xsi\ type="array"> \<item name="disabledproductsisindexablecondition" xsi\ type="object">klevu\indexingproducts\service\determiner\disabledproductsisindexablecondition\</item> \<item name="oosproductsisindexablecondition" xsi\ type="object">klevu\indexingproducts\service\determiner\outofstockproductsisindexablecondition\</item> \</argument> \</arguments> \</virtualtype> custom conditions you can add conditions to amend the default behaviour let's say you only wanted to index products when the attribute color was pink you’d inject your condition in to the isindexabledeterminer via the isindexableconditions array in your di xml vendor/module/etc/di xml \<virtualtype name="klevu\indexingproducts\service\determiner\isindexabledeterminer"> \<arguments> \<argument name="isindexableconditions" xsi\ type="array"> \<item name="pinkproductisindexablecondition" xsi\ type="object">vendor\module\service\determiner\pinkproductisindexablecondition\</item> \</argument> \</arguments> \</virtualtype> create that class, which must implement the isindexableconditioninterface vendor/module/service/determiner/pinkproductisindexablecondition php \<?php namespace vendor\module\service\determiner; use klevu\indexingapi\service\determiner\isindexableconditioninterface; class pinkproductisindexablecondition implements isindexableconditioninterface { public function execute( extensibledatainterface|pageinterface $entity, storeinterface $store, ) bool { if (!($entity instanceof productinterface)) { throw new \invalidargumentexception( sprintf( 'invalid argument provided for "$entity" expected %s, received %s ', productinterface class, get debug type($entity), ), ); } return $entity >getattributetext('color') === 'pink'; } } see klevu\indexingproducts\service\determiner\disabledproductsisindexablecondition as an example of a determiner condition