xczenter image description here

I want to hide my custom module menu based on configuration. If in configuration it set to "yes" then the menu should display and if set to "no" then menu should not appear at admin.

I have below code for add menu:

 <add id="Name_Module::parent" title="title" module="Name_Module" sortOrder="51" resource="Name_Module::parent"/>
 <add id="Name_Module::shippinglocation" title="Manage title" module="Name_Module" sortOrder="40" parent="Name_Module::parent" action="controller/action" resource="Name_Module::module"/>

How can i achieve this?



1 Answer 1


You can use dependsOnConfig="section/group/field"


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
        <add id="Vendor_Module::abcd" title="Title" module="Vendor_Module" sortOrder="100" resource="Vendor_Module::abcd" dependsOnConfig="section/group/field"/>        

Also for the other options too, you can check the xsd mentioned above i.e Magento_Backend:etc/menu.xsd

  • thanks, will it be work with store wise? in my code i have two lines of menu on which i need to do use "dependsOnConfig" ? Dec 19, 2018 at 12:07
  • Sorry if I am misinterpreting you but the menu is viewed inside the admin panel so how it can be store wise? Please explain the use case? you can add "dependsOnConfig" in any/all menu(s) in your menu.xml
    – Sarvagya
    Dec 19, 2018 at 12:14
  • To stop module's functionality for particular store is a different thing which needs to put config check inside the logic.
    – Sarvagya
    Dec 19, 2018 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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