Hello Readers,
This tutorial will guide you about controller overriding using config.xml. Here i am giving an example "to override Customer AccountController".
Lets start by creating the following folders:
app/code/local/Custom/Registration/etc
app/code/local/Custom/Registration/controllers
1. Create a file config.xml (under /app/code/local/Custom/Registration/etc).
<?xml version="1.0"?>
<config>
<modules>
<Custom_Registration>
<version>1.0.1</version>
</Custom_Registration>
</modules>
<frontend>
<routers>
<customer>
<args>
<modules>
<custom_registration before="Mage_Customer">Custom_Registration_Customer</custom_registration>
</modules>
</args>
</customer>
</routers>
</frontend>
</config>
<custom_registration before="Mage_Checkout">Custom_Registration_Customer</custom_registration> tag tell Magento that firstly load our custom controller files before the mage_customer core files.
2. Create a controller file "app/code/local/Custom/Registration/controllers/Customer/AccountController.php" and paste the following contents in that file.
<?php
require_once 'Mage/Customer/controllers/AccountController.php';
class Custom_Registration_Customer_AccountController extends Mage_Customer_AccountController
{
public function createAction()
{
echo "Account controller is overriden"; die;
}
}
3. Next step is to tell Magento to load our module and to do this we need to create a file Custom_Registration.xml under /app/etc/modules and paste the following code:
<?xml version="1.0"?>
<config>
<modules>
<Custom_Registration>
<active>true</active> // is active or not
<codePool>local</codePool> //location of the module i.e inside the local folder
</Custom_Registration>
</modules>
</config>
0 Comment(s)