Magento:尝试覆盖控制器 [英] Magento: Attempting to override a controller

查看:134
本文介绍了Magento:尝试覆盖控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想覆盖核心的CustomerController massDelete动作。这是我到目前为止:

So I am trying to override the core CustomerController massDelete action. This is what I have so far:

config.xml

<frontend>
  <routers>
    <customer_massdelete>
      <args>
        <modules>
          <MyModule_MyExtension before="Mage_Adminhtml">MyModule_MyExtension</MyModule_MyExtension>
        </modules>
      </args>
    </customer_massdelete>
  </routers>
</frontend>

我的控制器:

app/code/local/MyModule/MyExtension/controllers/CustomerController.php

<?php
require_once 'Mage/Adminhtml/controllers/CustomerController.php';
class MyModule_MyExtension_CustomerController extends Mage_Adminhtml_CustomerController {
  public function massDeleteAction() { 
   die('my controller');
  }
}

然而,当我运行大量删除放在他们的控制器上运行。任何想法?

Yet when i run a mass delete the die that i put in their controller is run instead. Any ideas?

更新:

p>

Tried out solution as follows:

<config>
  <admin>
    <routers>
      <adminhtml>          
        <args>
          <modules>
            <MyModule_MyExtension before="Mage_Adminhtml">MyModule_MyExtension</MyModule_MyExtension>
          </modules>
        </args>
      </adminhtml>
    </routers>
  </admin>
</config>

还没有...

strong> UPDATE 2:

UPDATE 2:

我最后的config.xml是这样的:

My final config.xml was like this:

<config>
  <admin>
    <routers>
      <adminhtml>      
        <args>
          <modules>
            <Mymodule_Myextension before="Mage_XmlConnect_Adminhtml">Mymodule_Myextension</Mymodule_Myextension>
          </modules>
        </args>      
      </adminhtml>
    </routers>
  </admin>
</config>

但是,如果我有before =Mage_XmlConnect_Adminhtml,那么当尝试转到大多数索引页。然而,如果我走任何较低的优先级,它不会覆盖。所以我再次被困。

However, if I have before="Mage_XmlConnect_Adminhtml" then I get some override issues when trying to go to most index pages. However if I go any lower in priority it doesn't override. So I am stuck again.

推荐答案

经过大量的研究,我终于找出了问题。我的问题是在 config.xml 中的 before =Mage_Adminhtml。由于企业工作的方式,不足以覆盖顶级类。

So after a lot of research I finally figured out the issue. My issue was with the before="Mage_Adminhtml" in config.xml. Due to the way enterprise works it was not enough to override the top level class.

我使用 print_r(Mage :: getConfig() - > getNode('admin / routers / adminhtml'),true)找出覆盖它的所有模块,并通过列表。 Mage_XmlConnect_Adminhtml 是在企业方法之前覆盖此方法的最后一个类。

I used print_r(Mage::getConfig()->getNode('admin/routers/adminhtml'), true) to figure out all the modules overriding it and worked through the list. Mage_XmlConnect_Adminhtml was the last class that overrode this method before enterprise methods.

我最后的config.xml是这样的:

My final config.xml was like this:

<config>
  <admin>
    <routers>
      <adminhtml>      
        <args>
          <modules>
            <Mymodule_Myextensionbefore="Mage_XmlConnect_Adminhtml">Mymodule_Myextension</Mymodule_Myextension>
          </modules>
        </args>      
      </adminhtml>
    </routers>
  </admin>
</config>

现在可以正常工作(编辑:Nope it does not ...见下面的评论)

It now works perfectly ( Nope it doesnt...see comment below)

这篇关于Magento:尝试覆盖控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆