Magento: Overriding a Controller

You can override a controller in Magento in following way.
Steps to override a controller in Magento:
1) When we override the controller in the module, we should not change the core controller files directly. To do this, we add following xml in config.xml inside our custom module:
                        <mynamespace_checkout before="Mage_Checkout">Mynamespace_Checkout</mynamespace_checkout>


2) We create a new custom class in our controllers folder in our custom module.
For Controller to be overrided: app/code/local/Mynamespace/Checkout/controllers/CartController.php
class Mynamespace_Checkout_CartController extends Mage_Checkout_CartController
// your code logic to be implemented here
Thats's it! You have your overrided controller.


Leave a Reply