magento复写core中的controller

发布 : 2016-07-07 分类 : IT 浏览 :

先在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
<?php
require_once Mage::getModuleDir('controllers', "Mage_Customer").DS."AccountController.php";
class Nano_App_AccountController 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>
本文作者 : 小凡
原文链接 : https://16bh.github.io/2016/07/07/magento-rewrite-core-controller/
版权声明 : 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
留下足迹