Magento 2, PHP
Lets override catalog product ListProduct block.
Step: 1 – First of all create di.xml file in Folder Done/Hello/etc
<?xmlversion="1.0"?><configxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"><preferencefor="Magento\Catalog\Block\Product\ListProduct"type="Done\Hello\Block\Rewrite\Product\ListProduct"/></config>
Step:2 – Now create ListProduct.php Block file in Folder Done/Hello/Block/Rewrite/Product
<?phpnamespaceDone\Hello\Block\Rewrite\Product;classListProductextends\Magento\Catalog\Block\Product\ListProduct{publicfunction_getProductCollection(){// Do your stuff here}}
You can override other blocks using same approach.