When we want to create a system config we add section items in the system.xml file. In these sections we specify a tab. That tab needs to also be defined. There is a possibility that a tab is already defined (with all the translations and sort order values), so when one adds a section, there is no need to redefine that tab again (with all the translations and sort order values).

Here the problem arises. What if the tab was defined in another module and we need to use in this module? If we just reference the tab then we need to specify the module as a dependency. If we redefine the tab then we do something that we actually have no intention in doing! If we create another module that just holds the tab it kind of solves the problemm but it is actually a utility module which is not that good of a practice; also other developers might not even know there is a module that's purpose is to be used to reference a tab.

At this stage though it still might seem that arguably the solution with the use of utility module has some justification (despite the drawbacks I've mentioned). However things get worse when we want to reference an admin menu. In that case we would need another utility module that would just have a menu. And as a consequence we would need even yet another module that would store the ACL resource for it. ACL resource, btw doesn't necessarily mean it is used in the admin only; when dealing with API permissions, these ACL are used as well (outside of admin scope); which means we absolutely need the separate between the menu utility and the acl resource one (because menu is an admin entity and the acl one is not necessarily). So with this approach it clearly becomes a nightmare to manage, remember and actually comunicate well with the team members so that it is properly reused.

It leads us to square one. To reuse with the dependency or to redefine? The problem with the reusing is the risk of choosing the wrong module (circular dependency); for instance there are five modules that use the same tab. How to decide which one should be the one that actually defines it? If we redefine, then it's just annoying; why on Earth a dev would need to specify the sort order over and over again when in fact one just want to stick a section into the system config tab!

And this is actually an important issue! I've faced this problem with ACL resource scenario with Magento upgrade; it happened when some inventory modules were referencing some resources that were not there, but these modules didn't have these dependencies listed: the whole admin did not work; and there are forums, posts and questions about it like: WTF, I've upgraded a version and now the whole thing is messed up! And the answers are: disable or enable some modules as a fix. That is ridiculous, in my opinion.

Anyway, looking for some guidance and opinions! Thanks!

And for ****'s sake, don't close my question for reasons like "opinion-based", "vague" and etc. I see this architectural deadend as a legitimate problem that I really really keen to resolve!


2 Answers 2


Mods, can we please close his question? No, but for real, I don't even see a question :D

If the tab was defined in a module that you are sure that will always be available, like core Magento 2 code, reuse the tab. I don't see why you would use a tab that is created in a different module, which might, or might not exist/active. Create a tab for your Vendor folder, and go from there. Or, if you, for some reason, want to reuse a tab declared in another module, just copy the declaration, so you have it in your code. Just like the security tab is declared 3 times in core modules.

enter image description here

I wonder how many tabs you have if it takes so much time to sort them? :)

If this still doesn't work for, maybe check if the module that declares the tab is enabled before checking config values? \Magento\Framework\Module\Manager::isEnabled

  • My question is about which one is preferred option: to declare the config somewhere else to reuse it OR to keep redeclaring the same tab over and over again. The problem with multiple declarations is that if you keep doing extra job (not that obvious with the case of tab, but more obvious with the case of menu. When declaring menu you have to declare the resource. Resource in contrast to sortOrder is not cosmetic and needs to be carefully evaluated. It means that when one redeclares it there is some sort of dependency since one has to find the original declaration and copy/paste it
    – pro100tom
    Feb 16, 2022 at 9:08
  • It means that if one wants to change the resource, one has to do it for each declararion and this is already bad. But if there was another module where a resource is declared then one doesn't need to redeclare it, just add that module as a dependency instead. But that approach convolutes the repo with tiny utility modules. I am trying to weight for and against different approaches here
    – pro100tom
    Feb 16, 2022 at 9:12
  • And the tabs I would like to resure are not core. With the core tabs I would never have that problem. You don't see how it can be that a third party module tab can be used when that module is not there? Here is an example: you are an agency that has it's own namespace. You create a tab in admin config, like Mageplaza or Amasty. As an agency you have multiple modules that use that tab, but also these modules are not related to each other at all. The client says: we don't want one of these modules. You remove it, tab is gone!
    – pro100tom
    Feb 16, 2022 at 9:15
  • I am not an architect, so, can not weigh in on this, but, from what I have seen in a case you mentioned, with an agency, the packages we are using (different vendors, not the ones mentioned), we have some that come with a core module, and others that do not. For the vendor we are using, which has a separate tab created, it is being declared in each module, just like I pasted the screenshot for security. I do like DRY code, but, in this case, I would choose to declare it in each module, just to be on the safe side. I feel like this is question is opinionated, no certain "way" to do it.
    – Dan Staver
    Feb 17, 2022 at 4:11

I have decided to create a module called [CompanyName]_Base where this stuff is defined. I've seen Amasty has is done and it has convienced me it's a good way to add stuff that can be shared such as a menu tab with it's resource. Same can be applied with the system tab. It's not too granular, yet solves the problem of re-declaration. In fact one can't (kind of) re-declare a menu item because the convention is that the menu ID contains the module name and the resource that has the module name in it.

So I guess this is a good-enough solution. Still not fully sure, but in the meantime I am happy to settle with this approach.

I hope this answer helps other developers as well who have this problem. Just be careful when deciding what should go to that Base and what should not; really easy to make it a dump; be mindful of SRP, however word Base is extremely abstract. But I guess that's fine.

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.