1

I have overridden a template file by specifying the path in requirejs-config.js file like so:

var config = {
    map: {
        '*': {
              'Magento_Checkout/template/form/element/email.html': 
              'Vendor_Module/template/form/element/email.html'
        }
  }
};

I tried to create a new module that overrides the same file with the same technique:

 var config = {
        map: {
            '*': {
                  'Magento_Checkout/template/form/element/email.html': 
                  'Vendor_AnotherModule/template/form/element/email.html'
            }
      }
    };

In the browser, I can see that only the second - AnotherModule is overriding and the changes from the first Module are being ignored.
How to override the same file from two different modules so that both of the edits are shown?

1

1 Answer 1

1

For that, you need to manage the sequence of that both module. For more information please check following examples.

Update your module.xml file at Vendor/Module/etc/module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="2.0.0">
        <sequence>
            <module name="Magento_Checkout"/>
        </sequence>
    </module>
</config>

And following code for Another Module.

Update your module.xml file at Vendor/AnotherModule/etc/module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Vendor_AnotherModule" setup_version="2.0.0">
        <sequence>
            <module name="Magento_Checkout"/>
            <module name="Vendor_Module"/>
        </sequence>
    </module>
</config>

Once you made above changes you need to run following command.

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy

Hope this will help you for what you want. :)

6
  • @konstantin-patroev have you tried this solution.? Is this working for you.? Apr 6, 2018 at 9:20
  • Isn't the sequence only going to determine the order, therefore only showing changes from AnotherModule? Apr 6, 2018 at 9:29
  • @KonstantinPatroev At last, try this because this solution work for me that's why I have suggested you. Apr 6, 2018 at 9:36
  • @KonstantinPatroev Please let me know if these working for you? Apr 6, 2018 at 9:38
  • Even if it worked I would have to have knowledge of what all the other extensions are overriding! This wouldn't be a good solution if i wanted it to be compatible with any other extensions Apr 6, 2018 at 9:45

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.