2014-06-09

Rewrite controllers in magento

For rewriting controller in magento you have to add to your module config.xml:

 
  
   
    
     SliRx_Test
    
   
  
 

where Mage_Checkout - module with a controller which you are going to rewrite.
SliRx_Test - your module which contains the controller for rewrite.

The above config means that magento will search the controller in your module first and after that, if doesn't find it, in Mage_Checkout.
Then you have to create the file SliRx/Test/controllers/CartController.php:
require_once(Mage::getModuleDir('controllers', 'Mage_Checkout') . DS . 'CartController.php');

class SliRx_Test_CartController extends Mage_Checkout_CartController
{
    public function indexAction()
    {
        echo "it's cart!";
    }
}
But magento doesn't know about Mage_Checkout_CartController and you must include the file with this class by yourself. That's why before declaring SliRx_Test_CartController calls require_once;

No comments:

Post a Comment