I'm trying to create a custom indexer on Magento2.
I defined a mview.xml
and one indexer.xml
as follows:
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="my_indexer" view_id="my_indexer" class="My\Indexer\Model\Indexer\Fulltext">
<title translate="true">My Indexer</title>
<description translate="true">My Indexer</description>
</indexer>
</config>
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="my_indexer" class="My\Module\Model\Indexer\Fulltext" group="indexer">
<subscriptions>
<table name="catalog_product_entity" entity_column="entity_id" />
<table name="catalog_product_entity_int" entity_column="entity_id" />
<table name="catalog_product_entity_decimal" entity_column="entity_id" />
<table name="catalog_product_entity_text" entity_column="entity_id" />
<table name="catalog_product_entity_varchar" entity_column="entity_id" />
<table name="catalog_product_entity_datetime" entity_column="entity_id" />
<table name="catalog_product_website" entity_column="product_id" />
<table name="cataloginventory_stock_item" entity_column="product_id" />
<table name="catalog_product_bundle_selection" entity_column="parent_product_id" />
<table name="catalog_product_super_link" entity_column="product_id" />
<table name="catalog_product_link" entity_column="product_id" />
</subscriptions>
</view>
</config>
I can see the new indexer in the Magento backend and I can run a reindex from the command line, but when I try to modify a product from backend it does not trigger the mview as I would expect.
It does not call the execute
method in the Mview or Indexer class, but it works correctly if called from command line.
Any idea?