I'm trying to override product list page but changes are not getting reflected in front end as it still referring to the core block.

Following is the code,


<?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\Block\Product\ListProduct" 
            type="TestApp\Blog\Block\Rewrite\Product\ListProduct" />


namespace TestApp\Blog\Block\Rewrite\Product;
use Magento\Framework\View\Element\Template;
class ListProduct extends \Magento\Catalog\Block\Product\ListProduct{
    protected function _getProductCollection()
        return null;
  • So this means your override is not working. Or some other module may have override same file. So enable path hint with show block name and check which block class is loading
    – Kumar M
    Aug 20, 2018 at 11:35
  • Magento\Catalog\Block\Product\ListProduct\Interceptor This block is being shown. Aug 20, 2018 at 11:36
  • have you tried after command php bin/magento cache:flush and php bin/magento setup:di:compile also checke is there any module who has override same file?
    – kunj
    Aug 20, 2018 at 11:38
  • You code seems fine, clear cache and check if you module is enable.
    – Kumar M
    Aug 20, 2018 at 11:40
  • And if you have production mode enabled then run compile command
    – Kumar M
    Aug 20, 2018 at 11:41

1 Answer 1


You need to add di.xml file into the etc/frontend/di.xml file

make sure you flush the cache, di compile if you already did

I hope It's help for you

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.