TheExtensionLab / MegaMenu

Magento MegaMenu extension
27 stars 6 forks source link

Call to a member function getAllChildNodes() on null #51

Closed kkrieger85 closed 6 years ago

kkrieger85 commented 6 years ago

I get this error on category page: Fatal error: Call to a member function getAllChildNodes() on null in app/code/community/TheExtensionLab/MegaMenu/Block/Widget/Category/List.php on line 26

The method:

    protected function getLoadedMenuNodes()
    {
        $currentMenu = Mage::registry('current_menu');
        $childNodes = $currentMenu->getAllChildNodes();

        return $childNodes;
    }

I grep through whole project folder to find something like register('current_menu but I can't find anything.

By now I am not sure if its a bug or a feature I don't understand.

I use latest release 1.5.7

sprankhub commented 6 years ago

https://github.com/TheExtensionLab/MegaMenu/blob/b9a635b6e7702e1167b7073af697dc52648393f3/app/code/community/TheExtensionLab/MegaMenu/Model/Observer.php#L13

https://github.com/TheExtensionLab/MegaMenu/blob/b9a635b6e7702e1167b7073af697dc52648393f3/app/code/community/TheExtensionLab/MegaMenu/Model/Observer.php#L24

This is done during the event page_block_html_topmenu_gethtml_before. Do you use Magento < 1.7?

kkrieger85 commented 6 years ago

I use Magento 1.9.3.7.

solved this issue by disabling block_html cache.

sprankhub commented 6 years ago

Then you can close this issue I think ;-)

JamesAnelay commented 6 years ago

I don't have a great answer here - but I just want to say I don't recommend disabling block_cache completely.

I would recommend you check TheExtensionLab_MegaMenu_Model_Observer::pageBlockHtmlTopmenuGetHtmlBefore is being called correctly as a first step by adding Mage::log to that method.

Can also try with the default theme and then you can at-least identify if the issue is in your theme or not.

It sounds like the main Menu is being cached and therefore there is no need to register no longer exists. But another block on the page that is not cached it trying to grab it or atleast render it's children. Prehaps a second menu renderer?