重写由其他扩展程序重写的管理块

Ovi*_*diu 4 magento

我尝试重写sales_order_view这是我在config.xml中的内容

        <blocks>
        <adminhtml>
            <rewrite>
                <sales_order_view>Bitstream_FancourierSelfawb_Block_View</sales_order_view>
            </rewrite>
        </adminhtml>
        <bitstream_selfawb>
            <class>Bitstream_FancourierSelfawb_Block</class>
        </bitstream_selfawb>
    </blocks>
Run Code Online (Sandbox Code Playgroud)

Ofcorse,我在Bitstream/FancourierSelfawb/Block中有适当的文件

我只需要添加一个按钮,但查看其他模块,我看到该块已被覆盖.

        <blocks>
        <adminhtml>
            <rewrite>
                <sales_order_view>Fooman_EmailAttachments_Block_View</sales_order_view>
            </rewrite>
        </adminhtml>
    </blocks>
Run Code Online (Sandbox Code Playgroud)

如果我在Fooman模块的config.xml中对此进行评论,我可以看到我的按钮.否则,没有运气.有没有办法在不同的模块中两次覆盖相同的块?

clo*_*eek 7

app/etc/modules/Bitstream_FancourierSelfawb.xml添加一个depends节点.

<config>
    <modules>
        <Bitstream_FancourierSelfawb>
            ...
            <depends>
                <Fooman_EmailAttachments />
            </depends>
        </Bitstream_FancourierSelfawb>
    </modules>
</config>
Run Code Online (Sandbox Code Playgroud)

当然,你的Bitstream_FancourierSelfawb_Block_View课程必须Fooman_EmailAttachments_Block_View直接延伸而不是Mage原版.


如果您希望添加和使用Fooman扩展都可以使用,那么您将不得不采用更长的基于事件的方法.

  • 使用块时,您可以使用[模板提示](http://www.magentocommerce.com/blog/template-path-hints-tutorial-video/)来查找类名.我同意没有提供用于检测重写模型的工具.我知道的唯一方法是使用`echo get_class(Mage :: getModel('example/example'));` (2认同)