2

嗨,我必须在我自己的模块中扩展核心控制器,为此我引用以下链接 http://inchoo.net/tools-frameworks/how-to-extend-magento-core-controller/

下面是我的模块结构

/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
}
}

/var/www/magento1.9/app/code/local/Inchoo/Coreextended/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Inchoo_Coreextended>
            <version>0.1.0</version>
        </Inchoo_Coreextended>
    </modules>
    <frontend>
        <routers>
                <customer>
                    <args>
                        <modules>
                            <Inchoo_Coreextended before="Mage_Customer_AccountController">Inchoo_Coreextended_Frontend_Customer</Inchoo_Coreextended>
                        </modules>
                    </args>
                </customer>
        </routers>
    </frontend>
</config>

但是当我访问 http://localhost/magento1.9/index.php/customer/account/login/ 它时,它会显示核心登录操作并且它没有从我的模块切换,你能建议我在哪里做错了吗?

4

1 回答 1

3

我已通过更改以下文件来解决此问题:

应用程序/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>

代码池应该是代码池

于 2014-07-09T10:13:13.560 回答