php - Magento 客户模块覆盖不起作用

标签 php magento

我只想覆盖 magento 自定义帐户

我的文件夹结构是这样的

local
  Practise
    Coreextended
      controllers
        Frontend
          Customer
            AccountController.php
      etc
        config.xml

还有我的

AccountController.php

<?php
require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountControllerq.php';
    //we need to add this one since Magento wont recognize it automatically  
    class Practise_Coreextended_Frontend_Customer_AccountControllerextends Mage_Customer_AccountController
    {//here, you extended the core controller with our

        public function indexAction()
        { die('Here1');
        parent::indexAction();
        //you can always use default functionality
        }

        public function myactionAction()
        {
        die('Here2');
        //my code
        //you can write your own methods / actions
        }

        public function mymethod()
        {
        die('Here3');
        //my code
        //you can write your own methods
        }

        public function loginAction()
        {die('Here4');
        //finally you can write your code that will rewrite the whole core method
        //and you can call for your own methods, as you have full control over core controller
        }
    }

config.xml 是

<?xml version="1.0"?>
<config>
    <modules>
        <practise_coreextended>
        <version>0.2.0</version>
        </practise_coreextended>
    </modules>

    <frontend>
        <routers>
            <customer>
                <args>
                    <modules>
                        <practise_coreextended before="Mage_Customer_AccountController">
                            Practise_Coreextended_Frontend_Customer
                        </practise_coreextended>
                    </modules>
                </args>
            </customer>
        </routers>
    </frontend>

</config>

以及 app\etc\modules\Practise_Coreextended.xml 中的另一个文件

新模块显示在管理配置设置中。但是当我尝试导航登录页面时,没有任何模具正在打印。它仍然显示正常页面。 我是不是错过了什么...

最佳答案

最后你的 config.xml 应该是这样的:

<?xml version="1.0"?>
<config>
  <modules>
    <Practise_Coreextended>
      <version>0.1.0</version>
    </Practise_Coreextended>
  </modules>
  <frontend>
    <routers>
      <coreextended>
        <use>standard</use>
          <args>
            <module>Practise_Coreextended</module>
            <frontName>coreextended</frontName>
          </args>
      </coreextended>
    </routers>
  </frontend>
  <global>

        <rewrite>        
            <practise_coreextended_customer_accountcontroller>
                <from><![CDATA[#^/customer/account/#]]></from> <!-- Mage_Customer_AccountController  -->
                <to>/coreextended/customer_account/</to> <!-- Practise_Coreextended_Customer_AccountController  -->
            </practise_coreextended_customer_accountcontroller>
        </rewrite>

  </global>
  <admin>
    <routers>
      <coreextended>
        <use>admin</use>
        <args>
          <module>Practise_Coreextended</module>
          <frontName>admin_coreextended</frontName>
        </args>
      </coreextended>
    </routers>
  </admin>
</config> 

并检查您的 Controller 包含路径或使用下面的路径,'

<?php
require_once "Mage/Customer/controllers/AccountController.php";  
class Practise_Coreextended_Customer_AccountController extends Mage_Customer_AccountController{

}

更新:

还有你的Practise_Coreextended.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Practise_Coreextended>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </Practise_Coreextended>
  </modules>
</config>

并且您已经尝试使用不同的版本安装此模块(可能是)。最好清除 core_resource 表中的注册表(模块的条目)。只需打开此表并删除与此模块相关的任何条目。

最后删除 var/cache/中的缓存,如果您使用企业版,则清除 var/full_page_cache/。就是这样。

关于php - Magento 客户模块覆盖不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27169483/

相关文章:

php - Doctrine 有问题 :build-schema

php - 我的 php 代码没有正确添加

php - 将 HTML 代码转换为 XLS/XLSX

c# - 无法通过 Magento API 更新库存可用性/库存值(value)

php - 捕获已支付订单的正确 magento 观察者事件是什么?

mysql - Magento - 使用存储过程数组结果集作为集合

php - 区分更新和插入查询

php - 如何在 PHP 中将表情符号代码 ':)' 转换为笑脸表情符号

magento - 登录页面的重复内容问题

php - Magento - 更改新帐户电子邮件主题行的 css