How to Override Controller file in magento:
In this post, will see how to override controller file in magento. Basically we need to do following steps to override a controller file.
here will see how to override the checkout controller file.
Step: 1 Override you module xml file
app/etc/modules/Jute_Checkout.xml
<?xml version=”1.0″?>
<config>
<modules>
<Jute_Checkout>
<active>true</active>
<codePool>local</codePool>
</Jute_Checkout>
</modules>
</config>
Step: 2
Override you controller file. Which one you want override.Copy the CartController.php file from your base folder and replace to you local.
Copy from base\Checkout\controllers\CartController.php Paste into “local”. Here am overriding addAction function.Which function you want you override. Don’t copy entire functions (unless if required or not)
require_once ‘Mage/Checkout/controllers/CartController.php’;
class Jute_Checkout_CartController extends Mage_Checkout_CartController
{
public addAction()
{
}
}
Step: 3
Create config.xml file into you “local/Jute/Checkout” folder. Checkout below frontend node is required for override a controller file.
Config.xml
<?xml version=”1.0″?>
<config>
<modules>
<Jute_Checkout>
<version>0.0.1</version>
</Jute_Checkout>
</modules>
<global>
….
</global>
<frontend>
<routers>
<checkout>
<args>
<modules>
<jute_checkout before=”Jute_Checkout”>Jute_Checkout</jute_checkout>
</modules>
</args>
</checkout>
</routers>
</frontend>
</config>