2

In magento there is a module C and it depends on two module A and B. the module.xml of C is as follows:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Test_C" setup_version="2.0.0">
        <sequence>
            <module name="Test_A"/>
            <module name="Test_B"/>
        </sequence>
    </module>
</config>

Then the order of load module is A,B,C or B,A,C ???

  • <?xml version="1.0"?> <config xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Magento_C" setup_version="2.0.0"> <sequence> <module name="Magento_A"/> <module name="Magento_B"/> </sequence> </module> </config> – Jazz Apr 1 '19 at 2:16
0

The first one in the sequence will be the first to be loaded. In your case, you will be loading only A, and B.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Magento_C" setup_version="1.0.0">
        <sequence>
            <module name="Magento_A"/>
            <module name="Magento_B"/>
        </sequence>
    </module>
</config>  

It depends on which module you like to load first, you can interchange both module A and B.
UPDATE: The order of loading the module is A, B, then C.

| improve this answer | |
  • Okay but what if we change that order in composer.json that means here the order is A->B but in composer.json require we provide it as B->A?? – Jazz Apr 1 '19 at 2:19
  • regardless, composer require only checks if module A and B are installed otherwise module C will not install. – fmsthird Apr 1 '19 at 2:21
  • it doesn't really matter if the order in module.xml is A->B but in composer.json require it is B->A. – fmsthird Apr 1 '19 at 2:28
  • You're welcome, I hope my answer is helpful – fmsthird Apr 1 '19 at 2:31
0

Both load orders A,B,C or B,A,C satisfy the sequence you stated in your module.xml and there is no guarantee of one or the other.

If you wanted a fixed load order of A,B,C you would need to add a sequence in module B

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Magento_B" setup_version="1.0.0">
        <sequence>
            <module name="Magento_A"/>
        </sequence>
    </module>
</config>
| improve this answer | |
  • But what if module B doesn't depends on module A then it that case if our module A is not installed then our module B also doesn't installed? We only want to make our moduleC dependent on module A and B only in specific order. – Jazz Apr 1 '19 at 2:34
  • Let's move one step backward - what are you trying to achieve as your end goal? why do you need modules A and B in a specific order? – Kristof at Fooman Apr 1 '19 at 2:42

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.