---
title: Is Indexable Determiner
slug: klevu-magento-v4/entities-is-indexable-determiner
docTags: 
createdAt: 2024-08-06T15:44:59.995Z
---

## 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.&#x20;
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

:::CodeblockTabs
module-m2-indexing-products/etc/di.xml

```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`

:::CodeblockTabs
Vendor/Module/etc/di.xml

```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`&#x20;

:::CodeblockTabs
Vendor/Module/Service/Determiner/PinkProductIsIndexableCondition.php

```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.
