cancel
Showing results for 
Search instead for 
Did you mean: 

unable to reindex catalog_product_price

unable to reindex catalog_product_price

I  got this error when try to reindex catalog_product_price

php bin/magento indexer:reindex catalog_product_price

Notice: Undefined index: default in /public_html/vendor/magento/module-catalog/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculator.php on line 55

and from system.log

2019-11-27 20:03:04] main.ERROR: Cron Job indexer_reindex_all_invalid has an error: Notice: Undefined property: Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator::$_batchRowsCount in /public_html/vendor/magento/module-catalog/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculator.php on line 55. Statistics: {"sum":0,"count":1,"realmem":0,"emalloc":0,"realmem_start":138412032,"emalloc_start":134564184} [] []

 

There is no modification to BatchSizeCalculator.php

<?php/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price;

/**
 * Ensure that size of index MEMORY table is enough for configured rows count in batch.
 */
class BatchSizeCalculator
{
    /**
     * @var array
     */
    private $batchRowsCount;

    /**
     * @var \Magento\Framework\Indexer\BatchSizeManagementInterface[]
     */
    private $estimators;

    /**
     * @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductBatchSizeAdjusterInterface[]
     */
    private $batchSizeAdjusters;

    /**
     * BatchSizeCalculator constructor.
     * @param array $batchRowsCount
     * @param array $estimators
     * @param array $batchSizeAdjusters
     */
    public function __construct(array $batchRowsCount, array $estimators, array $batchSizeAdjusters)
    {        $this->batchRowsCount = $batchRowsCount;        $this->estimators = $estimators;        $this->batchSizeAdjusters = $batchSizeAdjusters;
    }

    /**
     * Retrieve batch size for the given indexer.
     *
     * Ensure that the database will be able to handle provided batch size correctly.
     *
     * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
     * @param string $indexerTypeId
     * @return int
     */
    public function estimateBatchSize(\Magento\Framework\DB\Adapter\AdapterInterface $connection, $indexerTypeId)
    {        $batchRowsCount = isset($this->batchRowsCount[$indexerTypeId])
            ? $this->batchRowsCount[$indexerTypeId]
            : $this->batchRowsCount['default'];

        /** @var \Magento\Framework\Indexer\BatchSizeManagementInterface $calculator */        $calculator = isset($this->estimators[$indexerTypeId])
            ? $this->estimators[$indexerTypeId]
            : $this->estimators['default'];        $batchRowsCount = isset($this->batchSizeAdjusters[$indexerTypeId])
            ? $this->batchSizeAdjusters[$indexerTypeId]->adjust($batchRowsCount)
            : $batchRowsCount;        $calculator->ensureBatchSize($connection, $batchRowsCount);

        return $batchRowsCount;
    }
}

 

4 REPLIES 4

Re: unable to reindex catalog_product_price

Hello @kris_wen 

 

Please try with below-shared changes in BatchSizeCalculator.php:55

 

$this->batchRowsCount['default'];

to

$this->batchRowsCount['configurable'];

  

Manish Mittal
https://www.manishmittal.com/

Re: unable to reindex catalog_product_price

Hi, this works. However, I am trying to find out what cause the issue? Do you have any insights? Thank you.

Re: unable to reindex catalog_product_price

@kris_wen 

will explore in deep this later and explain you. Thanks

Manish Mittal
https://www.manishmittal.com/

Re: unable to reindex catalog_product_price

Hi Manish,
Thanks a lot. Please do let me know. I have searched this for a few
days have find out the reason.

Thank you.