Indexing
...
Attributes
Discovery

Registering Attributes that are not Magento Attributes

1min

There may be cases where you need to index some entity data to Klevu where a Magento attribute does not represent that data.

e.g. For a product you want to send the following data in the entity payload

JSON


Where some_attribute is not a Magento attribute but is data pulled from some third-party source. With the Klevu JSON API, we must register some_attribute as an attribute before sending data for that attribute in the entity payload.

Klevu provides StaticAttributeProvider to accomplish this. Called “static” as they are hardcoded in the di.xml and cannot be updated via the admin or the database.

We add attributes to StaticAttributeProvider by injecting the required attribute(s) into the attributes argument via di.xml. e.g.

Vendor/Module/etc/di.xml


We can do the same for Categories injecting into Klevu\IndexingCategories\Service\Provider\StaticAttributeProvider

 

Updated 23 Sep 2024
Doc contributor
Doc contributor
Did this page help you?