我尝试覆盖控制器/app/code/core/Mage/Customer/controllers/AccountController.php
中的函数。
我创建模块文件夹:
/app/code/local/Mandarin/SkipLogoutSuccess/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Mandarin_SkipLogoutSuccess>
<version>0.1.0</version>
</Mandarin_SkipLogoutSuccess>
</modules>
<frontend>
<routers>
<checkout>
<args>
<modules>
<mandarin_skiplogoutsuccess before="Mage_Customer">Mandarin_SkipLogoutSuccess</mandarin_skiplogoutsuccess>
</modules>
</args>
</checkout>
</routers>
</frontend>
</config>
/app/code/local/Mandarin/SkipLogoutSuccess/controllers/AccountController.php
require_once 'Mage/Customer/controllers/AccountController.php';
class Mandarin_SkipLogoutSuccess_AccountController extends Mage_Customer_AccountController
{
public function logoutAction()
{
$this->_getSession()->logout()->setBeforeAuthUrl(Mage::getUrl());
Mage::log("its Allive!", null, 'mygento.log');
$this->_redirectUrl(Mage::getUrl());
}
}
/app/etc/modules/Mandarin_SkipLogoutSuccess.xml
<?xml version="1.0"?>
<config>
<modules>
<Mandarin_SkipLogoutSuccess>
<active>true</active>
<codePool>local</codePool>
</Mandarin_SkipLogoutSuccess>
</modules>
</config>
当我运行logoutAction时,从核心使用控制器。在我的日志文件中,我没有收到消息。 哪里可能是错误?
答案 0 :(得分:1)
我认为您制作了复制粘贴错误:
在config.xml中引用名称空间“&lt; checkout&gt;”但它应该是“&lt; customer&gt;” (当然还有结束标签)
答案 1 :(得分:1)
在你的config.xml中
<frontend>
<routers>
<customer> <!-- should be customer -->
在Mandarin_SkipLogoutSuccess.xml
<?xml version="1.0"?>
<config>
<modules>
<Mandarin_SkipLogoutSuccess>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Customer /> <!-- Make sure this is loaded first -->
</depends>
</Mandarin_SkipLogoutSuccess>
</modules>
</config>