Question

Magento version: 2.3.1

When I run inventory reindex from command line it first runs inventory reindex and then price reindex after that.

Here is the command I executed:

bin/magento indexer:reindex inventory

Output on console:

Inventory index has been rebuilt successfully in 00:00:40
Product Price index has been rebuilt successfully in 00:08:10
Catalog Search index has been rebuilt successfully in 00:25:01

As you can see from console output, price and catalog search reindex also executed.

How can I prevent running price reindex automatically? I want just inventory reindex.

Was it helpful?

Solution

Not exactly what you are look for, but this might be helpful.

As Eugene mentioned, to keep the data consistency price indexing is bound to inventory indexing.

Have a look at below code in the file vendor/magento/module-catalog-inventory/etc/mview.xml.

 <view id="catalog_product_price" class="Magento\Catalog\Model\Indexer\Product\Price" group="indexer">
        <subscriptions>
            <table name="cataloginventory_stock_item" entity_column="product_id" />
        </subscriptions>
    </view>

What this materialized view code does is, it adds a trigger to cataloginventory_stock_item table.

If your inventory indexing is configured to 'Update by Schedule' and when there is a change in product inventory in cataloginventory_stock_item table, it makes entry for product in table catalog_product_price_cl.

When price indexing runs, catalog_product_price_cl table is used to identify the product ids for which price indexing needs to run.

If you want to disable entry in catalog_product_price_cl table during inventory indexing, you need to override this file and comment the code and run setup:upgrade. It will remove the trigger from cataloginventory_stock_item table. Of course you need to verify that there isn't any data inconsistency after this modification.

OTHER TIPS

Described behavior may seem to be completely unobvious, however it's expected.

The thing is, that indexers may depend on each other, like in your case, Catalog Search indexer depends on Price indexer, which, in turn depends on Inventory index. This chain might not be optimal, however all of them must run to ensure data consistency, as inventory availability may impact data in the price index and so on.

Indexer dependencies are configured via DI configuration, and I believe it's possible to override this config for your specific case. However, this is not something I would recommend, as it may impact data consistency and correct display of catalog information.

Looking at the initial question I assume that you are concerned about performance. Have you looked into reindex on save or reindexing at a time when store does not experience biggest customer flows? This kind of problem may be mitigated in different ways depending on your business scenario. Please let us know the details and might find a solution together.

If you want to first runs inventory reindex and then price reindex after that.

You have to need run below command for individual selected indexer run.

php bin/magento indexer:reindex cataloginventory_stock

php bin/magento indexer:reindex catalog_product_price

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top