1

I had updated the magento version 2.3.5 to 2.4.2, in the admin when i tried to search the configurable product alone it shows the wrong product count. enter image description here

1 Answer 1

3

This is default issue in M2.4.2. A patch (MDVA-36615) is available for this issue in Commerce Edition, check here

To resolve it in community edition create preference for

Magento\Catalog\Ui\DataProvider\Product\ProductCollection and override the getSize() method with below code

 /**
 * @return int
 */
public function getSize()
{
    return parent::getSize();
}

Override in your custom module

Create di.xml

Vendor/Module/etc/di.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Catalog\Ui\DataProvider\Product\ProductCollection" type="Vendor\Module\Rewrite\Magento\Catalog\Ui\DataProvider\Product\ProductCollection"/>
</config>

Vendor/Module/Rewrite/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php

<?php
declare(strict_types=1);

namespace Vendor\Module\Rewrite\Magento\Catalog\Ui\DataProvider\Product;

class ProductCollection extends \Magento\Catalog\Ui\DataProvider\Product\ProductCollection
{
    /**
     * @return int
     */
    public function getSize()
    {
        return parent::getSize();
    }
}

Please check this thread for more details. Thanks!

8
  • Patch is available for commerce edition
    – Sabareesh
    Commented Jun 25, 2021 at 12:08
  • Yes tried this it shows the undefied AbstractDb
    – Sabareesh
    Commented Jun 25, 2021 at 12:22
  • Can you share what code you are trying in preference? Commented Jun 25, 2021 at 12:24
  • No, For testing i had checking in the vendor files.
    – Sabareesh
    Commented Jun 25, 2021 at 12:27
  • @Sabareesh I've upated my answer please check. Commented Jun 25, 2021 at 12:35

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.