Magento阻止来自两个不同模块的覆盖 [英] Magento block override from two different modules

查看:45
本文介绍了Magento阻止来自两个不同模块的覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在覆盖magento核心块时遇到了一些问题.在我的模块中,我需要覆盖Mage_Catalog_Block_Navigation

Hi I have some issues in overriding a magento core block. In my module I need to override Mage_Catalog_Block_Navigation

<blocks>
  <catalog>
    <rewrite>
            <navigation>Mycompany_Mymodule_Catalog_Block_Navigation</navigation>
        </rewrite>
  </catalog>
</blocks>

但这已被另一家公司的另一个magento扩展所覆盖:

but this is already overridden by another magento extension from another company:

<blocks>
  <catalog>
    <rewrite>
        <navigation>Othercompany_Othermodule_Block_Navigation</navigation>
    </rewrite>
  </catalog>
</blocks>

两个扩展名都覆盖了不同的方法,并且彼此之间彼此不了解,但是magento读取了第二个公司的覆盖而不是我的覆盖.我不想使用模块依赖项.有什么方法可以不破坏这两个扩展功能.

Both extension overrides different methods and they don't know abut each other, but magento reads the second company overrides and not my. I don't want to use module dependencies. Is there any way to not break the two extensions functionality.

推荐答案

是的,您必须确定哪个正式覆盖了核心块.让一个继承一个不进行覆盖的继承,让那个继承一个核心.

Yes, you have to decide which one officially overwrites the core Block. Have that one inherit the one that isn't doing the override, and have that one inherit the core one.

My_Custom_Block extends Other_Custom_Block
Other_Custom_Block extends Mage_Core_Block
Mage_Core_Block extends Whatever_Magento_Wants

编辑config.xml文件,以便只有My_Custom_Block是覆盖核心块的文件.

Edit the config.xml files so that only My_Custom_Block is the one that is overriding the core Block.

编辑 这是您需要的XML:

EDIT Here's the XML you need:

<blocks>
  <catalog>
    <rewrite>
            <navigation>Mycompany_Mymodule_Catalog_Block_Navigation</navigation>
        </rewrite>
  </catalog>
</blocks>

这篇关于Magento阻止来自两个不同模块的覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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