Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Module 覆盖Magento中自定义模块中的核心控制器_Module_Overriding_Customization_Extend_Magento 1.9.1 - Fatal编程技术网

Module 覆盖Magento中自定义模块中的核心控制器

Module 覆盖Magento中自定义模块中的核心控制器,module,overriding,customization,extend,magento-1.9.1,Module,Overriding,Customization,Extend,Magento 1.9.1,嗨,我必须在我自己的模块中扩展核心控制器。为此,我参考以下链接 下面是我的模块结构 /var/www/magento1.9/app/etc/modules <?xml version="1.0"?> <!--we need to enable this module as any other if--> <!--you wish to do it as standalone module extension--> <config> <

嗨,我必须在我自己的模块中扩展核心控制器。为此,我参考以下链接

下面是我的模块结构

/var/www/magento1.9/app/etc/modules

<?xml version="1.0"?>
<!--we need to enable this module as any other if-->
<!--you wish to do it as standalone module extension-->
<config>
    <modules>
        <Inchoo_Coreextended>
            <active>true</active>
            <codepool>local</codepool>
        </Inchoo_Coreextended>
    </modules>
</config>

真的
地方的
/var/www/magento1.9/app/code/local/Inchoo/Coreextended/controllers/Frontend/Customer/AccountController.php

<?php
require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
//we need to add this one since Magento wont recognize it automatically
class Inchoo_Coreextended_Frontend_Customer_AccountController extends Mage_Customer_AccountController
{//here, you extended the core controller with our
public function indexAction()
{
parent::indexAction();
//you can always use default functionality
}
public function myactionAction()
{
//my code
//you can write your own methods / actions
}
public function mymethod()
{
//my code
//you can write your own methods
}
public function loginAction()
{

    echo "hello";
//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
}
}

我已通过在以下文件中进行更改来修复此问题:

app/etc/modules/Inchoo_Coreextended.xml

之前:

<config>
    <modules>
        <Inchoo_Coreextended>
            <active>true</active>
            <codepool>local</codepool>
        </Inchoo_Coreextended>
    </modules>
</config>

真的
地方的
之后:

<config>
    <modules>
        <Inchoo_Coreextended>
            <active>true</active>
            <codePool>local</codePool>
        </Inchoo_Coreextended>
    </modules>
</config>

真的
地方的
codepool应该是codepool


关于前面提到的教程,我强烈建议避免标记内容中的任何制表符、空格、换行符等(就像教程中的控制器名称一样,因为制表符和换行符可能不会被修剪,扩展也不起作用)
<config>
    <modules>
        <Inchoo_Coreextended>
            <active>true</active>
            <codePool>local</codePool>
        </Inchoo_Coreextended>
    </modules>
</config>