0

I have a total of 7193 products in the catalog. 6704 simple and 489 configurable.

When reindexing, Magento iterates trough all price indexers and process them. I added some debug messages and found out that the bundle and group products takes very long to process. However, there are no bundle or grouped products in my catalog! I added a simple condition to skip the bundle and grouped types and the time to reindex prices went from 2:06 minutes to 14 seconds.

This is the file that iterates the indexers: vendor/magento/module-catalog/Model/Indexer/Product/Price/Action/Full.php

I'm thinking of building a plugin for that skip indexers based on product types not used... But I need to investigate a bit more. Anyone else noticed this problem?

1
  • Ok, so I found something. The indexers run in batches. The size of the batch is calculated based on how many websites, customer groups and max relation count. Max relation count is high because I have a lot of configurable products. But there is no need to run hundreds of batches for bundles since there are no bundle products at all.
    – Sandis
    Sep 18, 2019 at 7:30

1 Answer 1

0

A bit of a hack, but I created a plugin that ignores indexers I don't need.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Model\Indexer\Product\Price\AbstractAction">
        <plugin name="eoh-indexer-optimize-product-type-filter" type="Eoh\IndexerOptimize\Plugin\ProductTypeFilterPlugin" sortOrder="10"/>
    </type>
</config>

<?php

namespace Eoh\IndexerOptimize\Plugin;

use Magento\Catalog\Model\Indexer\Product\Price\AbstractAction;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceInterface;

class ProductTypeFilterPlugin
{

    /**
     * Ignore unnecessary indexers
     *
     * @param AbstractAction $subject
     * @param PriceInterface[] $result
     *
     * @return PriceInterface[]
     */
    public function afterGetTypeIndexers(AbstractAction $subject, $result)
    {
        unset($result['downloadable']);
        unset($result['virtual']);
        unset($result['bundle']);
        unset($result['grouped']);
        return $result;
    }

}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.