Magento2: Override Catalog Widget Block

When we override the widget block class, then due to some reason, we need to put related template file into the override block with the same directory path as original.

That’s why to override the catalogwidget, we need to follow given below steps:

1- Create di.xml file into your custom module.

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\CatalogWidget\Block\Product\ProductsList" type="BrijeshTech\CatalogWidget\Block\Product\ProductsList" />


2- Create a block file to extend the widget class:


namespace &nbsp; BrijeshTech\CatalogWidget\Block\Product;

class ProductsList extends \Magento\CatalogWidget\Block\Product\ProductsList
    public function customMethod()
       //do your action here



3- Copy the related template file and put into your custom module with related directory Path:

For this example, copy the file by going into given below path.



And put into your custom module’s view ditectory into given below path:


Hope, by this way your problem got fixed.

Leave a Reply

Your email address will not be published. Required fields are marked *