Magento Override Core Blocks

You can override Magento core blocks file by following method.
Please find the sample code below:

1) When we override the blocks or methods of blocks in the module, we should not change the core block files directly. To do this, we add following xml in config.xml inside the our custom module:

2) We create a new custom class in our block folder at path Mynamespace/Test/Block/Catalog/Product.php in our custom module.

class Mynamespace_Test_Block_Catalog_Product extends Mage_Catalog_Block_Product
Thats’s it! You have overrided the core block ‘Mage_Catalog_Block_Product’.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s