---
title: Discovery
slug: klevu-magento-v4/attribute-discovery
docTags: 
createdAt: 2024-08-06T14:15:09.367Z
---

## Attribute Discovery

:::hint{type="warning"}
Attribute discovery does not send any data to Klevu.

Its only purpose is to add missing attributes to the `klevu_indexing_attribute` database table or to set attributes that are no longer indexable to have a `next action` of `Delete`.
:::

Note: all Magento category and product attributes are added here, even if they do not currently need to be registered with Klevu.

Attribute discovery will:

- add any missing attributes and determine if those [attributes are indexable](https://docs.klevu.com/klevu-magento-v4/attribute-is-indexable-determiner).&#x20;
- set any attributes which are no longer indexable, but were previously registered, to have a `next_action` of `Delete`.&#x20;
- set any attributes that have become indexable to have a `next_action` of `Add`.&#x20;

Attribute discovery will **NOT**:

- determine if an attribute requires an update.
- send any data to Klevu.

Attribute discovery is triggered:

- on account integration
- via plugins
- via observers
- via cron
- via CLI

`\Klevu\Indexing\Service\AttributeDiscoveryOrchestratorService`is responsible for attribute discovery. All the above methods of triggering attribute discovery use this service.

### Cron

:::hint{type="info"}
As with all cron tasks added by version 4.x of the Klevu integration, attribute discovery cron tasks use the dedicated `klevu` cron group, allowing granular configuration of scheduling and run options.

We recommend using the native Magento cron to run these jobs, configuring schedules if necessary, rather than a custom server-side cron implementation of the CLI command.
:::

Attribute discovery runs once a day via cron.
The configuration for the cron can be found here `module-m2-indexing/etc/crontab.xml`

:::CodeblockTabs
module-m2-indexing/etc/crontab.xml

```xml
<job name="klevu_indexing_discover_attributes"
     instance="Klevu\Indexing\Cron\DiscoverAttributes"
     method="execute">
    <schedule>52 1 * * *</schedule>
</job>
```
:::

### CLI

`klevu:indexing:attribute-discovery`

The discovery can also be triggered via CLI and has 2 optional parameters&#x20;

- `api-keys` - \[optional] comma-separated list of API keys to run discovery for
- `attribute-types` - \[optional] comma-separated list of  attribute types to run discovery for, options:
  - `KLEVU_PRODUCT`&#x20;
  - `KLEVU_CATEGORY`

e.g

```shell
bin/magento klevu:indexing:attribute-discovery \
    --attribute-types="KLEVU_PRODUCT" \
    --api-keys="klevu-example-js-api-key"
    
```

