I created a custom storefront theme and override the catalog_product_view.xml file in my custom theme. Below is the path.


It's working as expected.

Now let's say I have downloaded a third party extension (EXTENSION1) which using set template for the reference product.info.addtocart in the same layout file i.e catalog_product_view.xml. like below

<action method="setTemplate">
    <argument name="template" xsi:type="string">Vendername_Modulename::product/view/addtocart.phtml</argument>

also uses sequence definition in their module.xml

    <module name="Magento_Catalog"/>

Now let's say there is one more third party extension (EXTENSION2) doing the same.

I have two questions

1. How Magento decide priority between Custom Theme, Extension1 Extension2.

Is there any naming convention?

1. How I make all functionality(Changes in custom theme, Extension1 and Extension2) works together.

Do I need to make a single file and merge all changes in one file?

2 Answers 2


Layout Merging Order

  1. Magento first merges layout files into the module's base area
  2. The request area module files are loaded (frontend or adminhtml). Above two are depend upon Module's load order, it can be controlled using sequence tag in module.xml and module's load order can be seen in app/etc/config.php
  3. Layout files in theme are loaded (current theme first and then the parent theme).

How I make all functionality(Changes in custom theme, Extension1 and Extension2) works together.

You need not to worry about merging because Magento does it as mentioned above. You just need to follow the order.
If you are customizing the same node/tag at multiple places then the last loaded will take the precedence and works.



Magento 2 Fall back logic:


Source : @Amit Bera

You hanven't to merge the layout files in one, Magento do it for you, it Merge all layout files into one xml file.

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.