2

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

app\design\frontend\Akhilg\custom\Magento_Catalog\layout\catalog_product_view.xml

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>
</action>    

also uses sequence definition in their module.xml

<sequence>
    <module name="Magento_Catalog"/>
</sequence>

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

1

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.

References:

0

Magento 2 Fall back logic:

current_theme/{Namespace_Module}/
parent_theme/{Namespace_Module}/
module_dir/view/frontend/
module_dir/view/base/

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 that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.