1

I'm trying to override a Block class called Smartwave_Megamenu_Block_Topmenu, which is declared like the following:

    <blocks>
        <catalog>
            <rewrite>
                <navigation>Smartwave_Megamenu_Block_Navigation</navigation>
                <!-- v1.4-1.6 -->
            </rewrite>
        </catalog>
        <page>
            <rewrite>
                <html_topmenu>Smartwave_Megamenu_Block_Topmenu</html_topmenu>
                <!-- v1.7 -->
            </rewrite>
        </page>
        <megamenu>
            <class>Smartwave_Megamenu_Block</class>
        </megamenu>
    </blocks>

As you can see this config.xml-Block node is rewriting html_topmenu of Mage_Core.

However, if I try to rewrite megamenu like the following:

    <blocks>
        <vendor_template>
            <class>Vendor_Template_Block</class>
        </vendor_template>
        <megamenu>
            <rewrite>
                <topmenu>Vendor_Template_Block_Topmenu</topmenu>
            </rewrite>
        </megamenu>
    </blocks> 

The same old Class is still loaded. Why is this happening and how can I rewrite this Block Class properly?

I've cleared caches, of course.

1

This way not working. You need to overwrite the core class and extend Smartwave_Megamenu_Block_Topmenu class.

Ex: First comment out the following line from Smartwave_Megamenu module config.xml


    <blocks>
        <catalog>
            <rewrite>
                <navigation>Smartwave_Megamenu_Block_Navigation</navigation>
                <!-- v1.4-1.6 -->
            </rewrite>
        </catalog>
        <!--
        <page>
            <rewrite>
                <html_topmenu>Smartwave_Megamenu_Block_Topmenu</html_topmenu>
            </rewrite>
        </page>
        -->
        <megamenu>
            <class>Smartwave_Megamenu_Block</class>
        </megamenu>
    </blocks>

Now overwrite your module config:


    <blocks>
        <vendor_template>
            <class>Vendor_Template_Block</class>
        </vendor_template>
        <page>
            <rewrite>
                <html_topmenu>Vendor_Template_Block_Topmenu</html_topmenu>
            </rewrite>
        </page>
    </blocks> 

After that :


class Vendor_Template_Block_Topmenu extends Smartwave_Megamenu_Block_Topmenu
{

}
1
  • Whoof, what a bummer. Usually Magento tends to be better then this... :/ Has worked perfectly fine! Thank you very much! – Max S Feb 19 '19 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.