Why doesn't this:

    <reference name="menu">
        <action method="setActive">

make my module's menu active but instead the Reports menu remains active? For context, I have a menu item which redirects to the products ordered report but I want my modules menu to be active as if the user is still in my menu.


Magento's core code is calling _setActiveMenu after it loads the layout. So your setActive gets called, but then Magento calls setActive again, so Magento wins.

Details: To render a Magento layout, the author of a controller action method needs to call


When they call loadLayout, that's the method which goes through the layout update XML, instantiates the configured blocks, and calls any <action/> methods.

In the report controllers, the soldAction method looks like this

#File: app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php
public function soldAction()
         ->_title($this->__('Products Ordered'));

        ->_addBreadcrumb(Mage::helper('reports')->__('Products Ordered'), Mage::helper('reports')->__('Products Ordered'))

So where's the call to loadLayout? Is happens in _initAction.

#File: app/code/core/Mage/Adminhtml/Controller/Report/Abstract.php
public function _initAction()
        ->_addBreadcrumb(Mage::helper('reports')->__('Reports'), Mage::helper('reports')->__('Reports'));
    return $this;

So, since the report controller calls loadLayout first, and then sets the active menu, your layout update XML can never win.

One possible solution is an event observer for controller_action_layout_render_before, and if the listener set the active menu if you're on the correct page (otherwise just return early from the observer)

| improve this answer | |

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.