Categories
Anchor Categories
Out of the box, the Klevu plugin respects the is_anchor category setting. To change this behaviour and ignore anchor categories you can add an before-plugin on ParentAnchorCategoryIdProvider and return an empty array. Setting categoryIds param as an empty array will return an empty array skipping any extra database calls.
<type name="Klevu\IndexingProducts\Service\Provider\Catalog\ParentAnchorCategoryIdProvider">
<plugin name="Vendor_Module::ParentAnchorCategoryIdProvider"
type="Vendor\Module\Plugin\Service\Provider\Catalog\ParentAnchorCategoryIdProviderPlugin"/>
</type>Create the Plugin class
<?php
namespace Vendor\Module\Plugin\Service\Provider\Catalog;
use Klevu\IndexingApi\Service\Provider\Catalog\ParentAnchorCategoryIdProviderInterface;
class ParentAnchorCategoryIdProviderPlugin
{
/**
* @param ParentAnchorCategoryIdProviderInterface $subject
* @param int[] $categoryIds
*
* @return int[]
*/
public function beforeGet(
ParentAnchorCategoryIdProviderInterface $subject,
array $categoryIds,
): array {
return [[]];
}
}Custom Attributes Name Prefix
As Magento has separate attributes for products and categories and these attributes can have the same name. Klevu does not differentiate attributes between types and therefore a name clash could occur with category and product attributes overwritting each other. To mitigate this we have added a prefix to any custom category attributes. By default this prefix is set to cat__.
<virtualType name="Klevu\IndexingCategories\Service\Mapper\MagentoToKlevuAttributeMapper"
type="Klevu\Indexing\Service\Mapper\MagentoToKlevuAttributeMapper">
<arguments>
<argument name="entityType"
xsi:type="const">Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE</argument>
<!-- CATEGORY ATTRIBUTE PREFIX -->
<argument name="prefix" xsi:type="string">cat__</argument>
<argument name="attributeMapping" xsi:type="array">
<item name="path" xsi:type="string">categoryPath</item>
<item name="url_key" xsi:type="string">url</item>
</argument>
</arguments>
</virtualType>You are free to change this prefix. Note: it is limited to underscores and alphanumeric characters only. If you change the prefix you’ll also need to ensure that any cat__attribute_code references in your pipeline YMAL files and/or frontend search requests are updated with the new prefix.
<virtualType name="Klevu\IndexingCategories\Service\Mapper\MagentoToKlevuAttributeMapper">
<arguments>
<argument name="prefix" xsi:type="string">prefix_</argument>
</arguments>
</virtualType>