====== How to overload a controller ======
In this example we're overloading Mage_Checkout_CartController::indexAction().
====1. Create your module folders and files====
- Magento/app/code/local/MyNameSpace/MyModule/etc/config.xml
- Magento/app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php
- Magento/app/etc/modules/MyNameSpace_All.xml
====2. Edit /etc/config.xml====
Go to Magento/app/code/local/MyNameSpace/MyModule/etc/config.xml and paste the following xml into it (comments I’m not a 100% sure about are ending with “(?)"):
0.1.0
/mymodule/checkout_cart/
MyNameSpace_MyModule
mymodule
====3. Edit /controllers/Checkout/CartController.php ====
Paste the following php code into Magento/app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php
(the only change we're doing to the indexAction() is adding an error_log() message):
====3. Edit Magento/app/etc/modules/MyNameSpace_All.xml====
(This is to activate your module)
true
local
====4. Edit Magento/app/design/frontend/[myinterface]/[mytheme]/layout/checkout.xml====
Add the following to use the same update handle as before:
====5. Point your browser to /checkout/cart/====
Take a look in your php error log and you should find ‘Yes, I did it!’.