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.
1 Answer
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!