【问题标题】:Magento: How to override admin controller outside of adminhtml?Magento:如何覆盖 adminhtml 之外的管理控制器?
【发布时间】:2013-12-11 23:49:26
【问题描述】:

简单地说,我想覆盖 Mage/Index/controllers/Admninhtml/ProcessController.php 中的 ProcessController。

我知道如何覆盖前端控制器,但这让我头疼了好几个小时。我不能让它工作。这是我的配置文件

<?xml version="1.0"?>

<config>
<global>
    <models>
        <twobuy_index>
            <class>Twobuy_Index_Model</class>
        </twobuy_index>                 
    </models>
</global>

<admin>
    <routers>
        <index>
            <args>
                <modules>
                     <Twobuy before="Mage_Index">Twobuy_Index</Twobuy>
                </modules>
            </args>            
        </index>
    </routers>
</admin>
</config>

以及控制器声明

 include_once('Mage/Index/controllers/Adminhtml/ProcessController.php');
 class Twobuy_Index_Adminhtml_ProcessController extends Mage_Index_Adminhtml_ProcessController
 {

我尝试覆盖 reindexAction,但我的方法从未被调用。

【问题讨论】:

  • 解决了!这是 标签,但我必须用 Twobuy_Index_Adminhtml 覆盖 Mage_Index_Adminhtml。谢谢大家的帮助!我希望 Magento 有更好的文档记录,有解释,而不仅仅是示例,这样我们就不必幸运地猜测解决方案了。
  • 你是如何扩展的?我也想像你一样扩展类似的。 Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php 我的 config.xml 是: 1.0.0DS_Adminextended 我的扩展未调用控制器类。类 DS_Adminextended_Adminhtml_Oauth_AuthorizeController 扩展 Mage_Oauth_Adminhtml_Oauth_AuthorizeController { }

标签: magento controller overriding


【解决方案1】:

在您的配置文件中将&lt;index&gt; 替换为&lt;adminhtml&gt;。这可能只是一个复制粘贴错误,但您的 &lt;Twobuy&gt; 标签错误地以 &lt;/Ucon&gt; 结尾。

【讨论】:

  • tnx 的答案,但 index->​​adminhtml 开关没有帮助 :( Twobuy 标签只是复制粘贴,它在我的配置中是正确的
【解决方案2】:

&lt;Twobuy before="Mage_Index"&gt;Twobuy_Index&lt;/Ucon&gt;

您的 XML 中似乎有错误

&lt;twobuy_index before="Mage_Index"&gt;Twobuy_Index&lt;/twobuy_index&gt;

【讨论】:

  • tnx 回答,在我的文件中没问题,只是复制/粘贴错误。我也尝试了你的建议,没有帮助
猜你喜欢
  • 2015-08-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-18
  • 1970-01-01
  • 1970-01-01
  • 2015-08-29
相关资源
最近更新 更多