How to Override a core controoler in magento ?? Magento controller class override is something different then others classes. Controller override is not same as model, helper, block override. I found lot of thread on magento forum , but not working for me (1.3.2.x), few hours debug, I got it .so how ? a example is override the ProductControoler ( I already create a module call Webcaker_Catalog),steps for override Step1 : add xml config to confg.xml
Webcaker_Catalog catalog ... #^/catalog/product/# /catalog/product/
Note: for from node, need use CDATA to warp it . Step2 : add new file ProductControler.php in the controllers in Webcaker/Catalog with code below
//important! Magento cannot load the ProductController automatically
require_once 'require_once 'Mage/Catalog/controllers/ProductController.php';
class Webcaker_Catalog_ProductController extends Mage_Catalog_ProductController
{
public function viewAction()
{
//your logic here
}
}
done , magento rock!
Big thx man! It’s works great.
Could You write some more explanation about this lines: 16. 17. 18. #^/catalog/product/# 19. /catalog/product/ 20. 21.
Usual You must to write what do You want to rewrite For example:
MyClientCompany_Catalog_Block_Product_List
I put node between because I want to rewrite block… In your example node in between . In the same level as . Is this mean that I want to rewrite controller, when I put rewrite node as child of ?
This notation:
^/catalog/product/
/catalog/product/ is also a little strange for me.
Once again, thanks for this post Best regards from Poland
hi Bartosz, I’m happy it’s useful for you, if you wanna override a block, you can do by this :
not sure it’s right magento’s way..
great!!!!! It’s the only Magento controller override works 4me!!!
thanks a lot! easy and neat!
caker, I’ll give u the source code of the world!
Nacho
nice tutorial but it didn't worked for me i am using version 1.4.0.1
Can you please upload the module files here?
and where is the etc/module/Namespace_modulename.xml file
Hi
It didn’t work for me.
…Buuut i think that i did something wrong.
Can you upload in an one-all package? (xml, php , folders, etc)
Thanks, Robert.