Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.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
Class Magento重载控制器_Class_Magento_Controller_Overloading_Router - Fatal编程技术网

Class Magento重载控制器

Class Magento重载控制器,class,magento,controller,overloading,router,Class,Magento,Controller,Overloading,Router,我知道有很多关于这个问题的例子,我想我读了所有的例子,至少我觉得是这样,有点困惑:-)我想首先我需要基本的conzept,分别更好地了解如何最好地改变整个客户前端仪表板,并用其他方法扩展它。我有点纠结于此,也许这是错误的方法,也许不是,希望你能帮我找到正确的方法 所有需要的文件都位于: app/code/local/Company/Customer/etc/config.xml app/code/local/Company/Customer/controller/AccountControlle

我知道有很多关于这个问题的例子,我想我读了所有的例子,至少我觉得是这样,有点困惑:-)我想首先我需要基本的conzept,分别更好地了解如何最好地改变整个客户前端仪表板,并用其他方法扩展它。我有点纠结于此,也许这是错误的方法,也许不是,希望你能帮我找到正确的方法

所有需要的文件都位于:

app/code/local/Company/Customer/etc/config.xml

app/code/local/Company/Customer/controller/AccountController.php

app/code/local/Company/Customer/controller/IndexController.php

Atm我使用这些路径:

domain.com/customer/

被以下内容覆盖:

<frontend>
    <routers>    
       <customer>
          <use>standard</use>
          <args>
             <module>Company_Customer</module>
             <frontName>customer</frontName>
          </args>
       </customer>
   </routers>
</frontend>
编辑:

这是error.log中的错误:

2011-07-25T10:36:46+00:00 ERR (3): Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'Mage/Customer/AccountController.php' for inclusion (include_path='/html/magento/app/code/local:/html/magento/app/code/community:/html/magento/app/code/core:/html/magento/lib:.:/usr/local/php/lib/php:/usr/local/php/lib/php/PEAR')  in /html/magento/lib/Varien/Autoload.php on line 93
2011-07-25T10:36:46+00:00错误(3):警告:include()[]:无法打开“Mage/Customer/AccountController.php”进行包含(include_path='/html/magento/app/code/local:/html/magento/app/code/community:/html/magento/app/code/core:/html/magento/lib:.:/:/usr/local/php/lib/php:/usr/local/php/php/)在第93行的/html/magento/lib/Varien/Autoload.php中
我想这意味着路由器工作,但文件找不到,对吗

任何建议都很好。谢谢

------------------------------------------------------------

-----------更新--------------------

------------------------------------------------------------

谢谢你的回复。我在全局部分尝试了替代重写,之前:

<rewrite>
   <Company_Customer_Account>
      <from><![CDATA[#^/customer/account/#]]></from>
      <to>/customer/account/</to>
    </Company_Customer_Account>
</rewrite>

/客户/账户/
使用您的代码:

<rewrite>
    <Company_Customer_Account>
      <from>/customer/account/index/</from>
      <to>/customer/account/index/</to>
   </Company_Customer_Account>
</rewrite>

/客户/账户/索引/
/客户/账户/索引/
两者都不起作用,我错过了什么

这是AccountController.php

<?php

//require_once 'Mage/Customer/controllers/AccountController.php';

class Extension_Modul_AccountController extends Mage_Customer_AccountController {

    # Overloaded indexAction
    public function indexAction()
    {
        echo "executed";
        parent::indexAction();
    }
}

在第二个示例中,您的姓名“customer\u account”必须与前面的“customer”相同

当您执行domain.com/customer/时,它会自动引用IndexController->indexAction()

为了获得domain.com/customer/account,可以进行类似的操作,这里的account指的不是accountAction,而是AccountController

路径系统通常类似于:模块/SomeController/someAction

或者,您可以在配置全局标记中添加以下内容:

<rewrite><module_control_action><from>/module/control/action/</from><to>/mymodule/somecontrol/someaction/</to></module_control_action></rewrite>
/module/control/action//mymodule/somecontrol/someaction/

我认为您没有正确地重定向到原始文件。。。由于错误表明它无法找到
mage/customer/accountcontroller.php
,但您希望加载
app/code/core/mage/customer/controllers/accountcontroller.php
。。确保您已重定向到所需的位置one@kvijayhari是的,但我不想重定向到原始文件,我只想包含我自己的控制器,扩展原始文件,位于
app/code/local/Company/Customer/controllers/AccountController.php
。正如您所说,在
mage/customer/accountcontroller.php
中找不到该文件,这是正确的,因为我的模块目录中没有文件夹mage。但我必须做什么,才能得到正确的答案?你怎么知道它不起作用?它可能会自己替换上一个调用,因此您看不到区别。我认为frontname的问题在于它需要是customer,而且一个模块应该有一个frontname,顺便说一句,另外还需要AccountController.php和indexAction().如果我将
customer\u帐户
更改为
customer
我想路由器会调用我在Company/customer/controllers/IndexController.php中的allready现有控制器,没有办法并行运行这两个控制器吗?它调用相同的模块控制器,但如果您像domain.com/customer/account那样调用它,那么它将转到或查找AccountController indexAction。您应该坚持的简单理解是:yourdomain.com/your frontname/your controller/your action/any param/any param value。。。您可以有多个控制器。谢谢您的回复!如果我理解正确,你的意思是:我只需要定义一次对客户模块的重写?如果需要什么,在本例中是AccountController,路由器首先在控制器的扩展目录中查找?我在上面添加了AccountController.php
<rewrite><module_control_action><from>/module/control/action/</from><to>/mymodule/somecontrol/someaction/</to></module_control_action></rewrite>