---
title: Is Indexable Determiner
slug: klevu-magento-v4/attribute-is-indexable-determiner
docTags: 
createdAt: 2024-08-06T14:34:19.795Z
---

## Determiners & Conditions

If an attribute is indexable is determined by `Klevu\Indexing\Service\Determiner\IsAttributeIndexableDeterminer`
This determiner loops through all injected `Klevu\IndexingApi\Service\Determiner\IsAttributeIndexableConditionInterface` classes.
If **any** of these return false; then the attribute is set to **not indexable** and will not be registered with Klevu.&#x20;
If they **all** return true; then the attribute is indexable and can be registered with Klevu.

By default, the only setting checked to determine if an attribute is indexable is the new **Register with Klevu&#x20;**&#x73;etting on the attribute.

![](https://api.archbee.com/api/optimize/816_4eGYZQxALlijMlcBN/caUOqUccmlgPIwZfFr651_screenshot-2024-08-06-at-151355.png "Klevu Attribute Settings")

Both `module-ms-indexing-categories` and `module-m2-indexing-products` create virtual types of this class and inject an array of conditions.
e.g.

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

```xml
<virtualType name="Klevu\IndexingProducts\Service\Determiner\IsAttributeIndexableDeterminer"
             type="Klevu\Indexing\Service\Determiner\IsAttributeIndexableDeterminer">
    <arguments>
        <argument name="isIndexableConditions" xsi:type="array">
            <item name="indexTypeIsIndexableCondition"
                  xsi:type="object">Klevu\IndexingProducts\Service\Determiner\AttributeIsIndexableCondition</item>
        </argument>
    </arguments>
</virtualType>
```
:::

***

## Custom Conditions

You can add conditions to amend the default behaviour.
Let's say you only wanted to register attributes when the attribute code began with `vendor_`.
You’d inject your condition in to the `IsAttributeIndexableDeterminer` via the `isIndexableConditions` array in your `di.xml`

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

```xml
<virtualType name="Klevu\IndexingProducts\Service\Determiner\IsAttributeIndexableDeterminer">
    <arguments>
        <argument name="isIndexableConditions" xsi:type="array">
            <item name="indexTypeIsIndexableCondition"
                  xsi:type="object">Vendor\Module\Service\Determiner\AttributeCodeBeginsWithIsIndexableCondition</item>
        </argument>
    </arguments>
</virtualType>
```
:::

Create that class implementing the interface `Klevu\IndexingApi\Service\Determiner\IsAttributeIndexableConditionInterface`

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

```php
<?php

namespace Vendor\Module\Service\Determiner;

use Klevu\IndexingApi\Service\Determiner\IsAttributeIndexableConditionInterface;

class AttributeCodeBeginsWithIsIndexableCondition implements IsAttributeIndexableConditionInterface
{
    public function execute(
        AttributeInterface $attribute, 
        StoreInterface $store
    ): bool {
        return str_starts_with(
            haystck: $attribute->getCode(), 
            needle: 'vendor_',
        );
    }
}
```
:::

See `Klevu\IndexingProducts\Service\Determiner\AttributeIsIndexableCondition` as an example of a condition.
