0

I'm working on a custom Magento 2 indexer (Update by Schedule) for ElasticSuite virtual categories, but it's not being invalidated when I update a virtual rule in the admin.

What is missing to trigger the custom indexer invalidated when a virtual rule is updated?

Here's what I have:

<?php
declare(strict_types=1);
 namespace Vendor\Module\Model;
use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\Product;
use Magento\CatalogRule\Model\Rule;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Indexer\SaveHandler\Batch;
use Magento\Framework\Search\Request\DimensionFactory;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Catalog\Model\Product\Attribute\Source\Status;
use External\SearchModule\Api\Index\IndexOperationInterface;
use External\VirtualCategory\Model\Category\Attribute\VirtualRule\ReadHandler;
use Vendor\Module\Model\Action\Full;
use Vendor\Module\Model\ResourceModel\Link;
use Vendor\Module\Model\TableMaintainer;
/**
 * class Virtual Category products Indexer
 */
class Indexer implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface
{
 /**
 * @var string
 */
 public const INDEXER_ID = 'elasticsuite_virtual_categories';
 /**
 * @param StoreManagerInterface $storeManager
 * @param DimensionFactory $dimensionFactory
 * @param CategoryProductLink $defaultIndexerResource
 * @param CategoryProductLinkTableMaintainer $categoryProductLinkTableMaintainer
 * @param IndexOperationInterface $indexOperation
 * @param Batch $batch
 * @param ReadHandler $readHandler
 * @param Full $fullAction
 * @param ResourceConnection $resourceConnection
 */
 public function __construct(
 protected StoreManagerInterface $storeManager,
 protected DimensionFactory $dimensionFactory,
 protected CategoryProductLink $defaultIndexerResource,
 protected CategoryProductLinkTableMaintainer $categoryProductLinkTableMaintainer,
 protected IndexOperationInterface $indexOperation,
 protected Batch $batch,
 protected ReadHandler $readHandler,
 protected Full $fullAction,
 protected readonly ResourceConnection $resourceConnection
 ) {}
 /*
 * Used by mview, allows process indexer in the "Update on schedule" mode
 */
 public function execute($ids)
 {
 $this->logger->info('⚙️ Running Virtual Category Indexer - execute()');
 $this->logger->info('Product IDs passed: ' . json_encode($ids));
 //Used by mview, allows you to process multiple placed orders in the "Update on schedule" mode
 }
 /*
 * Will take all of the data and reindex
 * Will run when reindex via command line
 */
 public function executeFull()
 {
 
 }
 /*
 * Works with a set of entity changed (may be massaction)
 */
 public function executeList(array $ids)
 {
 //Works with a set of placed orders (mass actions and so on)
 }
 /*
 * Works in runtime for a single entity using plugins
 */
 public function executeRow($id)
 {
 //Works in runtime for a single order using plugins
 }
}

mview.xml

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Mview/etc/mview.xsd">
 <view id="elasticsuite_virtual_categories" class="....\Model\Virtual\Indexer" group="indexer">
 <subscriptions>
 <table name="catalog_category_entity" entity_column="entity_id" />
 <table name="catalog_category_entity_datetime" entity_column="entity_id" />
 <table name="catalog_category_entity_decimal" entity_column="entity_id" />
 <table name="catalog_category_entity_int" entity_column="entity_id" />
 <table name="catalog_category_entity_text" entity_column="entity_id" />
 <table name="catalog_category_entity_varchar" entity_column="entity_id" />
 </subscriptions>
 </view>
</config>

indexer.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
 <indexer id="elasticsuite_virtual_categories" view_id="elasticsuite_virtual_categories" class="....\Model\Virtual\Indexer">
 <title translate="true">ElasticSuite Virtual Category Indexing</title>
 <description translate="true">Reindex ElasticSuite catalog Virtual categories.</description>
 </indexer>
</config>
DarkBee
14.4k9 gold badges86 silver badges135 bronze badges
asked Jul 17, 2025 at 12:22

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.