magento复写core中的controller

先在controllers目录下新建Customer文件夹,建立Nano_App_AccountController类文件,继承原有的Mage_Customer_AccountController

app/code/local/Nano/App/controllers/Customer/AccountController.php
1
2
3
4
5
6
7
8
9
10
11
12
require_once Mage::getModuleDir('controllers', "Mage_Customer").DS."AccountController.php";
class extends Mage_Customer_AccountController
{
* Login post action
*/
public function loginPostAction()
{
echo 'login post has been rewritten';
}
}

再修改app模块的配置文件config.xml,在global标签下对AccountContoller进行复写

app/code/local/Nano/App/etc/config.xml
1
2
3
4
5
6
7
8
9
10
<global>
<!-......-->
<rewrite>
<Nano_App>
<from><![CDATA[#^/customer/account/loginPost/#]]></from>
<to>/app/customer/account/loginPost/</to>
</Nano_App>
</rewrite>
<!-......-->
</global>