I am coming from Wordpress development & now I started Magento module development.

I am following this tutorial.

I am just trying to add social sharing buttons to the product edit page.

According to their article,

Now go to the root directory of your Magento and navigate to vendor/magento/module-catalog/view/frontend/templates/product/view, and find the addtocart.phtml file.

Copy this file to your module in app/code/Cloudways/Mymodule/view/frontend/templates/catalog/product/view

So you can see that we are going to override the addtocart.phtml. So my question is, what happens another module override same file? Loss my changes?

  • 2
    it depends on the modules sequence Mar 7, 2019 at 12:41
  • @PhilippSander It means, if two modules override the same file, definitely one module doesn't work as expected? Mar 8, 2019 at 5:38
  • can't say that per-say. it depends on what the modules do Mar 11, 2019 at 8:06

1 Answer 1


It depends on sequence of your module.

In module.xml you add all modules on which your module depends. Magento will make sure to load your module after all of these modules.


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_ComponentB" setup_version="0.0.1">
        <!-- Vendor_ComponentB is dependent on Vendor_ComponentA: -->
            <module name="Vendor_ComponentA" />


The module which will load in the end will overwrite the files of previous modules.

app/code/etc/config.php is auto generated file which has all modules list and modules loading sequence.

  • and your theme will always overwrite module templates Mar 7, 2019 at 13:14
  • Question is about when module override same file. It is not about frontend theme. Mar 8, 2019 at 5:03
  • @IsmailZafar It means, if two modules override the same file, definitely one module doesn't work as expected? Mar 8, 2019 at 5:39
  • @IamtheMostStupidPerson see this file app/code/etc/config.php. The module which comes later can overwrite the module which comes earlier. Mar 8, 2019 at 6:20

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.