Page tree
Skip to end of metadata
Go to start of metadata

In this example we’re overloadingMage_Checkout_CartController::indexAction().

1. Create your module folders and files

  1. app/code/local/MyNameSpace/MyModule/etc/config.xml
  2. app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php
  3. app/etc/modules/MyNameSpace_All.xml

2. Edit /etc/config.xml

Create app/code/local/MyNameSpace/MyModule/etc/config.xml with the following content:

 Expand source

Note: The above didn’t work for me when I override catalog/product controller. I had to use:

  1.                 <from><![CDATA[#^catalog/product/#]]></from>
  2.                 <to>mymodule/mycontroller</to>

(notice the missing leading slash)

Since Magento 1.3 you can simply add your module to the frontend router. Rewrites are not neccessary any more:

 Expand source


Please note that before=”Mage_Checkout” will load your controller first if available and fall back to Magento’s if not.

If the controller is in another folder, you’ll have to modify the code:app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php. Replace

  1.     <MyNameSpace_MyModule before="Mage_Checkout">MyNameSpace_MyModule</MyNameSpace_MyModule>


  1.     <MyNameSpace_MyModule before="Mage_Checkout">MyNameSpace_MyModule_Checkout</MyNameSpace_MyModule>

3. Edit ''controllers/Checkout/CartController.php''

Create app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php with the following content: (the only change to indexAction() is adding an error_log() call):

 Expand source

Edit ''app/etc/modules/MyNameSpace_All.xml''

(This is to activate your module)

 Expand source

Edit ''app/design/frontend/[myinterface]/[mytheme]/layout/checkout.xml''

Add the following to use the same update handle as before:

  1. <mynamespace_mymodule_checkout_cart_index>
  2.     <update handle="checkout_cart_index"/>
  3. </mynamespace_mymodule_checkout_cart_index>

(Note that these tags seem to be case sensitive. Try using all lowercase if this isn’t working for you)

[by Hendy: When I override catalog/product/view using the method described in this Wiki or here, I didn’t have to do the above. However, when using the 'cms way', I had to update the handle manually.]

The above item did not work for me (2009-02-19 by Jonathan M Carvalho)

I discovered that the file to change is app/design/frontend/[myinterface]/[mytheme]/layout/mymodule.xml

Add the following lines:

  1. <mynamespace_mymodule_checkout_cart_index>
  2.     <update handle="checkout_cart_index"/>           
  3. </mynamespace_mymodule_checkout_cart_index>

7. Point your browser to /checkout/cart/

In your PHP error log, you should find ‘Yes, I did it!’.

You need to be extra precise with the rewrite regular expression because errors are very hard to find.

  • No labels