15

We already know design fallback logic from Magento 1.x:

  1. Current package / Current Theme
  2. Current Package / Default theme
  3. Base Package / Default theme

Now. i want to know What is the design fallback logic in Magento 2.x for theme, layout & template files?

Please describe briefly.

12

The point is, compared to Magento 1, where a pseudo fallback mechanism was implemented. Magento 2 has a mechanism that falls back as many times as a parent theme can be found. The system is very similar to the one introduced on Magento 1.9 using theme.xml files.

For instance, when you have 5 themes inheriting from each other, then the mechanism will fall back to each one of them. The package is not taken into consideration anymore.

Here is a pseudo code that can describe the new design mechanisme:

do
    look in the current theme
    current theme will be parent theme on the next iteration
while the current theme has a parent theme

look in the view folder of the module area if the layout/template is not defined in the previous steps

As an example of static file fallback, suppose there is a request for the logo.svg image in the Blank theme.

Using theme inheritance and view file fallback rules, Magento uses the following search order:

  1. app/design/frontend/Magento/blank/web/images/logo.svg
  2. app/design/frontend/Magento/blank/web/logo.svg
  3. app/design/frontend/Magento/parent_theme/web/images/logo.svg
  4. app/design/frontend/Magento/parent_theme/web/logo.svg

Reference: http://devdocs.magento.com/guides/v2.0/architecture/view/static-process.html

  • nice share @Raphel.What about layout &template? – Amit Bera Apr 4 '16 at 10:47
  • @AmitBera I've edited my answer as the example provided was kind of confusing in the first part of my answer. – Raphael at Digital Pianism Apr 4 '16 at 10:50
  • @RaphaelatDigitalPianism The reference link provided gives 404, it would also be great if you can include design fallback on modules. – Vivek Kumar Dec 27 '18 at 15:17
1

Current fallback logic of theme:

  1. Current_theme/<Namespace>_<Module>/
  2. parent_theme(s)/<Namespace>_<Module>/
  3. module_dir/view/frontend/
  4. module_dir/view/base/

This pattern has used for layout and template also.

0

The fallback logic in Magento 2 is completely different from Magento 1, and associated with the theme inheritance feature.

According to the document:

The fallback order is slightly different for static assets (CSS, JavaScript, fonts and images) and other theme files, layouts and templates.

You can check more details in the document via this link: https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/themes/theme-inherit.html

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.