creativestyle/magesuite-elasticsuite-virtual-category-indexer

ElasticSuite Virtual Category Indexer

v1.2.0 2024-10-24 08:05 UTC

README

Configuration

To enable virtual category indexer or change a cron schedule go to:

  • Admin area
  • Store
  • Conffiguration
  • Magesuite
  • Virtual Category Indexer
  • General

CLI Commmand

Cron

Full reindexation is runing automaticaly by cron schedule.

Important module classes

Extension attribute

Module provide the extension attribute virtual_query to modify request to elasticsaerch using the plugin. If it has true smile works standardly. False value remove virtual query request.

See: \Smile\ElasticsuiteVirtualCategory\Model\Rule::getCategorySearchQuery

public function getCategorySearchQuery($category, $excludedCategories = []): ?QueryInterface
{
    $query = null;

    if (!is_object($category)) {
        $category = $this->categoryFactory->create()->setStoreId($this->getStoreId())->load($category);
    }

    if (!in_array($category->getId(), $excludedCategories)) {
        $excludedCategories[] = $category->getId();

        if ((bool) $category->getIsVirtualCategory() && $category->getIsActive()) {
           $query = $this->getVirtualCategoryQuery($category, $excludedCategories, $category->getData('virtual_category_root'));
        } elseif ($category->getId() && $category->getIsActive()) {
            $query = $this->getStandardCategoryQuery($category, $excludedCategories);
        }
        if ($query && $category->hasChildren()) {
            $query = $this->addChildrenQueries($query, $category, $excludedCategories);
        }
    }

    return $query;
}

EAV attribute

Module install a new category attribute virtual_category_reindex_required. If this attribute has value=1 smile works standardly.

Troubleshooting and todo in the future

When change root category of virtual category, previous products still are in the category

To remove product from categories run full reindexation.

After turn on module, virtual category does not display products anymore

If you see products on the preview in admin area:

it seems that ES is able to return the right product IDs in the indexer.

Make sure that the script provides the right category object here:

vendor/creativestyle/magesuite-elasticsuite-virtual-category-indexer/Model/Indexer/VirtualCategoryIndexer.php:150

should be the same as here:

vendor/creativestyle/magesuite-elasticsuite-virtual-category-indexer/Controller/Adminhtml/Category/Virtual/Preview.php:67