How to rewrite/extend a Magento class in an existing third party extension

女生的网名这么多〃 提交于 2021-02-07 18:16:28

问题


I'm trying to extend the class of a third party Magento extension.

My module xml:

within config>modules> tags

<EDPA_MegaNavigation>

        <active>true</active>

        <codePool>local</codePool>

        <depends>
            <Infortis_UltraMegamenu />
        </depends>

    </EDPA_MegaNavigation>

My Config xml:

within config>global>blocks> tags

 <ultramegamenu>

       <rewrite>

           <Infortis_UltraMegamenu_Block_Navigation>EDPA_MegaNavigation_Block_Navigation</Infortis_UltraMegamenu_Block_Navigation>

       </rewrite>

   </ultramegamenu>

My extended class (Navigation.php) has

class EDPA_MegaNavigation_Block_Navigation extends Infortis_UltraMegamenu_Block_Navigation
{
########
}

Within system>configuration>advanced EDPA_MegaNavigation is listed and shows as enabled.

My target navigation.php within Infortis>UltraMegamenu>Block is not being rewritten.

Any help/guidance much appreciated.


回答1:


Here the issue in if Infortis_UltraMegamenu module block tag is ultramegamenu then

<ultramegamenu>

       <rewrite>

           <navigation>EDPA_MegaNavigation_Block_Navigation</navigation>

       </rewrite>

   </ultramegamenu>



回答2:


Your <rewrite> doesn't look to be set up properly, it's supposed to reference another config node and not a direct class name. Check the UltraMegamenu's config.xml to get the node from it.

e.g. If UltraMegamenu is set up like:

<blocks>
    <ultramegamenu>
        <class>Infortis_UltraMegamenu_Block_Navigation</class>
    </ultramegamenu>
</blocks>

Then your rewrite child node would be "ultramegamenu" instead of the class name.



来源:https://stackoverflow.com/questions/24145976/how-to-rewrite-extend-a-magento-class-in-an-existing-third-party-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!