问题
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