6

TL:DR;
How can I rebuild (automatically) the modules sequence stored in app/etc/config.php in Magento 2.
Long version:
I have 2 modules I'm working on.
I installed them in the order "Module 1", "Module 2".
So in my app/etc/config.php they appear at the bottom like this:

'Magento_Wishlist' => 1, //core module
'Namespace_Module1' => 1, //my first module
'Namespace_Module2' => 1, //my second module

But after I installed both of them, I realized that Module2 must be loaded before Module1 so that some config settings from Module 2 can be overwritten through Module 1. (don't ask why, just bear with me).

So I edited the etc/module.xml file of "Module1" and added the "Module 2" inside the <sequence> tag.
But that has no effect, because the list of modules from config.php remains the same.
Is there a way to rebuild the sequence from config.php? I know that for 2 modules it should be easy because I can just edit it manually, but I'm curious if there is an automated way of doing it, in case I will need it in the future.

  • Did you try disabling/re enabling both modules ? Setup upgrade ? – Raphael at Digital Pianism Oct 21 '16 at 8:34
  • I guess that could work, but I was trying not to disable them. I was hoping for a clean approach. And I don't even think that both need to be disabled. One should be enough. You can put that as an answers, and If nobody comes with a solution that does not involve disabling modules I will take that. – Marius Oct 21 '16 at 8:35
7

From the documentation: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/build/module-load-order.html

If you change the component load order using <sequence>, you must regenerate the component list in config.php; otherwise, the load order does not take effect.

Currently, the only way to do this is to enable the component using magento module:enable <module-list>, where <module-list> is the component or components to which you added <sequence>.

  • Ah. Since this is from the documentation it must be the only valid option. I guess I have to go with this. – Marius Oct 21 '16 at 8:48
  • I find that if you don't use the right keywords you can miss useful information on the documentation – Raphael at Digital Pianism Oct 21 '16 at 8:54

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.