---
title: Sync
slug: klevu-magento-v4/entities-sync
docTags: 
createdAt: 2024-08-06T15:35:37.616Z
---

:::hint{type="info"}
Entity sync is responsible for sending entity data to Klevu.&#x20;

The type of API request depends on the `next_action` column in the `klevu_indexing_entity` database table. If that column is set to `Add` then an add request will be sent, if it is empty no request will be sent.
:::

Entity sync is triggered:

- via cron
- via CLI

`\Klevu\Indexing\Service\EntitySyncOrchestratorService` responsible for entity sync. All the above methods of triggering entity sync use this service.

### Cron

:::hint{type="info"}
As with all cron tasks added by version 4.x of the Klevu integration, entity sync 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.
:::

Entity sync runs every 30 minutes by default. This can be configured in the Magento admin, `Stores > Configuration > Klevu > Data Sync > Indexing > Entity Indexing Sync Frequency`.
The default setting can be found here `module-m2-indexing/etc/config.xml`
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_sync_entities"
     instance="Klevu\Indexing\Cron\SyncEntities"
     method="execute">
    <config_path>klevu/indexing/entity_cron_expr</config_path>
</job>
```
:::

### CLI

`klevu:indexing:entity-sync`

The sync can also be triggered via CLI and has 2 optional parameters

- `api-keys` - \[optional] comma-separated list of API keys to update
- `entity-types` - \[optional] comma-separated list of entity types to sync,
  &#x20;options:
  - `KLEVU_PRODUCT`
  - `KLEVU_CATEGORY`
  - `KLEVU_CMS`

Increasing the verbosity of the command will give you more information using `-v`, `-vv`, or `-vvv`

e.g

```shell
bin/magento klevu:indexing:entity-sync \
    --entity-types="KLEVU_PRODUCT" \
    --api-keys="klevu-example-js-api-key" \
    -vvv
```

### Data

If an attribute has been registered with Klevu for indexing that does not mean it is automatically sent to Klevu. It means it can be sent to Klevu.&#x20;

Entity data indexed to Klevu is defined in the [indexing pipelines](https://docs.klevu.com/klevu-magento-v4/entities-pipelines) YAML files.&#x20;
For custom attributes, you can either&#x20;

- enable autogeneration of the YAML files in the admin at `Stores > Configuration > Klevu > Developer Settings > Pipelines > Enable autogeneration of configuration overrides` and select the product types to send this data for in `Automatically Generate Pipeline Configuration For` section of the attribute properties.
- add your own YAML file for the attribute - see [pipelines customisation](https://docs.klevu.com/klevu-magento-v4/entities-pipelines-customisation)

