Magento:覆盖客户帐户控制器 [英] Magento: Overriding customer account controller
问题描述
我正在尝试覆盖Mage_Customer_AccountController,以便可以扩展createPostAction方法.在我的一生中,我似乎无法做到这一点,它要么抛出404页面,这表明该文件的路径不正确,或者默认为原始文件.
Hi I'm trying to override Mage_Customer_AccountController, so that I can extend the createPostAction method. For the life of me I can't seem to do this, it either throws a 404 page, which suggests that its not the right path for the file or it defaults to orignal.
<rewrite>
<company_modulename_account>
<from><![CDATA[#^/customer/account/#]]></from>
<to>/modulename/account</to>
</company_modulename_account>
</rewrite>
我的控制器位于此处local/company/modulename/controllers/AccountController.php
My controller is located here local/company/modulename/controllers/AccountController.php
推荐答案
相反,您可以尝试:
...
<frontend>
<routers>
<customer>
<args>
<modules>
<company_modulename before="Mage_Customer">Company_Modulename</company_modulename>
</modules>
</args>
</customer>
</routers>
</frontend>
...
并使用以下代码创建一个控制器类:
app/code/[codePool]/Company/Modulename/controllers/AccountController.php
And create a controller class:
app/code/[codePool]/Company/Modulename/controllers/AccountController.php
with the following code:
require_once 'Mage/Customer/controllers/AccountController.php';
class Company_Modulename_AccountController extends Mage_Customer_AccountController
{
public function createPostAction(){
die('Overriden');
}
}
有关控制器覆盖的更多信息:
https://stackoverflow.com/a/7117076/887385
Here is more info about controller overriding:
https://stackoverflow.com/a/7117076/887385
祝你好运!
这篇关于Magento:覆盖客户帐户控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!