Nov 16, 2011

Magento: Overriding Product Controller.

Edit you Package/Module/etc/config.xml



<?xml version="1.0"?>
<config>
... Your Other config here ....
<frontend>
<routers>
<catalog>
<args>
<modules>
<Package_Catalog before="Mage_Catalog">Package_Catalog</Package_Catalog>
</modules>
</args>
</catalog>
</routers>
</frontend>
</config>


Now your controller already ready.



include(Mage::getBaseDir()."/app/code/core/Mage/Catalog/controllers/ProductController.php");
class Package_Catalog_ProductController extends Mage_Catalog_ProductController
{
public function viewAction(){
echo __METHOD__;
}
}
?>



Try to access: http://192.168.101.188/catalog/product/view


2 comments:

Anonymous said...

Hello, thank you for sharing. I can not run your code. Is it possible to share a zip file containing all the necessary files?

jo

Winzter said...

I will try to post a zip for the code. For a while try to read reference.

NOTE: The main important to be able to override is the part on the config.xml

The routers section.

<Package_Catalog before="Mage_Catalog">Package_Catalog</Package_Catalog>