I developed some extensions, and I'm installing on various merchants. I'm trying to add a menu item (first level) with my vendor name, and on the second level the menu items of my extensions.

The problem is, if I define for an extension the first level menu item, the other extensions cannot redefine the same menu item. I should add only the second level menu items indicating the parent.

The only solution I found is what some vendors are actually doing. Creating a base/core extension.

Is this the only way to do what I need to? I don't like having to install an extension only for that... It's not possible to do a simple "create if not exist" for example?

Why with system.xml we don't have this problem? You just define all what you want, and if something it's redefined nothing happens, no error and not duplicated item.

Well I only wanted to know if exists alternatives


Indeed this is a problem.
The "problem" is that the menu.xml is imperative.
It uses directives like add, update, remove.
You don't have this problem in system.xml is declarative and nodes with the same id are merged.
I guess the solution is to create a base module that will only add your main menu item and make your other extensions depend on that main one.
But for the mental sanity of the devs that are going to use your extension, please don't do that.
Please don't group your extensions under the same roof just for the sake or marketing.
Put the menu items of each extension you have inside the main menu item where it fits.
You affect the catalog, put it under catalog. You affect the sales, put it under sales. You get the idea.
This is just an advice, not a solution.
This way you keep the merged menu split by functionality not by module developer. It really helps a developer and a shop user more.
On the other hand, if you create dependent modules there is no problem to nest the dependent extension menu item inside the main extension menu item since the main one is needed for the secondary one to function.

  • In fact, my merchant demand this: Having all our extensions grouped on the menu item. It's just shortcuts to system.xml so I'm not worrying so much. I tried using the directive update and seems it works. If don't exist the menu item it creates, and if already exists, it updates. This is what I wanted. But doing this can impact the performance?
    – Marc Pont
    Aug 1 '17 at 7:12
  • Theoretically it impacts it but I don't think it's significant. Theoretically every line of code you write affects performance :).
    – Marius
    Aug 1 '17 at 7:23
  • Yep of course, I was thinking the same. Ty
    – Marc Pont
    Aug 1 '17 at 7:35

I think the only way is the one you mentioned. Like to create another module named core or backend which always brings the first level menu item and then your other modules just add a second level.

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.