Magento – How to Override Core Checkout Cart Controller

controllersoverrides

I have already included a custom controller in my local module.

The config.xml snippet for it is:

       <routers>
          <subscription>
              <use>standard</use>
              <args>
                 <module>Born_Subscription</module>
                 <frontName>bornsubscription</frontName>
             </args>         
        </subscription>
       </routers>

Now I want to override Mage/Checkout/CartController as well in the same module.

How do I modify my config.xml file to include the override as well.

Best Answer

Add this inside the <routers> tag in your config.xml (as a sibling tag for subscription)

 <checkout>
     <args>
         <modules>
             <Born_Subscription before="Mage_Checkout">Born_Subscription</Born_Subscription>
         </modules>
     </args>
 </checkout>

Then create the file Born/Subscription/controllers/CartController.php with this content

<?php 
require_once 'Mage/Checkout/controllers/CartController.php';
class Born_Subscription_CartController extends Mage_Checkout_CartController
{
    //your magic code here
}
Related Topic