Indexing
...
Entities
Custom Entity Types

Entity Sync

3min

After discovering the entities, we need to sync them with Klevu by injecting EntityIndexerService services into the EntitySyncOrchestratorService. We inject a separate service for each action, i.e. Add, Delete and Update e.g.

Vendor/Module/etc/di.xml


Now create each of the injected EntityIndexerService.

You can create your own service classes that implement \Klevu\IndexingApi\Service\EntityIndexerServiceInterface and handle indexing the data with Klevu. If you choose this route please refer to the Klevu PHP-SDK documentation.

If you wish to use Klevu pipelines to index data with Klevu please continue following the example below.

Create a virtual type of Klevu\Indexing\Service\EntityIndexerService. Repeat this step for Delete and Update

Vendor/Module/etc/di.xml


Create a virtualType of Vendor\Module\Service\Provider\Sync\EntityIndexingRecordProvider (which doesn't exist yet) to set the action to be performed. Repeat this step for Delete and Update actions

Vendor/Module/etc/di.xml


Now create the missing Vendor\Module\Service\Provider\Sync\EntityIndexingRecordProvider mentioned in the previous step. This is a virtual type of Klevu\Indexing\Service\Provider\Sync\EntityIndexingRecordProvider. Pass in the same entityProvider we created during Custom Entity Types Entity Discover section.

Vendor/Module/etc/di.xml


Create Vendor\Module\Service\EntityIndexingRecordCreatorService which implements Klevu\IndexingApi\Service\EntityIndexingRecordCreatorServiceInterface

php


Final step is to create the pipeline YAML file to process that data before it is sent to Klevu. Vendor_Module::etc/pipeline/add_update.yml. See Pipelines.