4

In Magento 2, when you add a menu item, you need to specify a module attribute (module="Magento_Backend" below)

<add id="Magento_Backend::system_currency" 
     title="Currency" 
     module="Magento_Backend" 
     sortOrder="30" 
     parent="Magento_Backend::stores"
     action="adminhtml/system_currency"         
     resource="Magento_CurrencySymbol::system_currency"
/>

What does the Magento system use this attribute for? i.e., why does the menu rendering need to know which module a Menu Item comes from?

4

From what I've seen the main reason is to be able to hide the menu item if the module output is disabled.

In app/code/Magento/Backend/Model/Menu/Item.php you can find the following function where $this->_moduleName represents the value of the module attribute of the menu:

public function isDisabled()
    {
        return !$this->_moduleManager->isOutputEnabled(
            $this->_moduleName
        ) || !$this->_isModuleDependenciesAvailable() || !$this->_isConfigDependenciesAvailable();
    }

This is only from my experience and there may be more reasons.

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.