Indexing
Attributes
Attribute Mapping
3min
it is possible to map magento attributes to klevu attributes via di xml the modules already map some attributes where the names in klevu and magento differ e g magento's short description to klevu's shortdescription the current product attribute mapping can be found in module m2 indexing products/etc/di xml and looks like this module m2 indexing products/etc/di xml \<virtualtype name="klevu\indexingproducts\service\mapper\magentotoklevuattributemapper" type="klevu\indexing\service\mapper\magentotoklevuattributemapper"> \<arguments> \<argument name="attributemapping" xsi\ type="array"> \<item name="image" xsi\ type="null"/> \<item name="klevu image" xsi\ type="string">image\</item> \<item name="klevu rating" xsi\ type="string">rating\</item> \<item name="klevu rating count" xsi\ type="string">ratingcount\</item> \<item name="quantity and stock status" xsi\ type="string">instock\</item> \<item name="short description" xsi\ type="string">shortdescription\</item> \<item name="url key" xsi\ type="string">url\</item> \</argument> \</arguments> \</virtualtype> adding mapping for attributes if instead of using the magento attribute description for the klevu attribute description you wanted to use my custom attribute create your own module and add etc/di xml like this vendor/module/etc/di xml \<virtualtype name="klevu\indexingproducts\service\mapper\magentotoklevuattributemapper"> \<arguments> \<argument name="attributemapping" xsi\ type="array"> \<item name="my custom attribute" xsi\ type="string">description\</item> \</argument> \</arguments> \</virtualtype> now if you access my custom attribute in magento admin you’ll see that the klevu section can no longer be updated as it is mapped to a standard klevu attribute and standard klevu attributes are immutable however, the description attribute will be editable as it is no longer mapped to a standard klevu attribute if description is also set to be registered with klevu this will cause an issue as there are 2 magento attributes mapped to the same klevu attribute (if no mapping is in place then an attribute will use its attribute code) therefore mapping for description would also be required e g vendor/module/etc/di xml \<virtualtype name="klevu\indexingproducts\service\mapper\magentotoklevuattributemapper"> \<arguments> \<argument name="attributemapping" xsi\ type="array"> \<item name="my custom attribute" xsi\ type="string">description\</item> \<item name="description" xsi\ type="string">someotherfield\</item> \</argument> \</arguments> \</virtualtype> or vendor/module/etc/di xml \<virtualtype name="klevu\indexingproducts\service\mapper\magentotoklevuattributemapper"> \<arguments> \<argument name="attributemapping" xsi\ type="array"> \<item name="my custom attribute" xsi\ type="string">description\</item> \<item name="description" xsi\ type="null"/> \</argument> \</arguments> \</virtualtype>