The Magento 2 admin interface must be kept simple. Any unnecessary menu should be removed in order to keep the admin panel as clean as possible. Also, if you manage multiple admin users, you may want to hide some menu items from some of the users.
In case of the Magento 2 extensions, if it’s disabled from the configuration section, it’s useless to show menu items in the admin panel which occupies the space and make the menu lengthy. It’s where you need to disable admin menu items by configuration value in Magento 2.
However, it may not be feasible all the time to entirely remove a menu or tab altogether. You may need it when the requirements differ.
The below screenshots show how the admin menu tab is enabled and then disabled based on the configuration value:
The solution will fetch the configuration value, if it’s disabled, it will hide the menu items:
Method To Disable Admin Menu Items By Configuration Value in Magento 2:
Add the below code snippet in menu.xml file:
<add id="Vendor_Extension::Extension" resource="Vendor_Extension::extension"
module="Vendor_Extension" title="Extension" sortOrder="20" dependsOnConfig="section_id/group_id/field_id" />
Here, the value of “section_id/groupe_id/field_id” is based on the system configuration value.
An easy way to keep the backend admin panel sorted!
I’d be happy to solve any doubts on the topic that you may mention in the Comments section below.
I’d be very grateful if you helped share this helpful post on social media to fellow developers!
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.