0

我尝试覆盖控制器中的功能/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 控制器时。在我的日志文件中,我没有收到消息。错误可能在哪里?

4

2 回答 2

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>
于 2013-05-04T21:55:33.613 回答
1

我认为您犯了复制粘贴错误:

在您的 config.xml 中,您引用了命名空间“<checkout>”,但它应该是“<customer>”(当然还有结束标签)

于 2013-05-04T21:43:14.737 回答