In this blog tutorial, i will explain how to override magento blocks using an XML- based configuration file. Config.xml is module configuration file in which we will override magento block.
As magento best practices, we should not change any core files to implement custom features because it is a bad programming if core files are modified.
Create config.xml file of custom module.
Path: "app/code/local/My/Pant/etc/config.xml" and paste the following contents in that file.
<config>
<global>
<blocks>
<catalog>
<rewrite>
<view>My_Pant_Block_View</view>
</rewrite>
</catalog>
</blocks>
</global>
</config>
Now, create a block file "app/code/local/My/Pant/block/View.php" and paste the following contents in that file.
class My_Pant_Block_View extends Mage_Catalog_Block_Category_View
{
public function getProductListHtml()
{
return $this>getChildHtml('product_list');
}
}
0 Comment(s)