Categories


Archives


Recent Posts


Categories


Infinite Inheritance for theme.xml Layout Updates

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

In his soon to be referenced widely Magento Infinite Theme Fallback Fix, Eric Wiese notes that layout update XML files added via theme.xml are ignored by the parent/child theme inheritance. An XML file added to a parent’s theme.xml will not be added automatically to the child theme’s layout.

Eric’s solution is a custom module that makes theme inheritance consider these files.

If installing a module isn’t a solution available to you, here’s another option. Just specify the file from the parent theme you’d like in the child’s theme.xml.

In Eric’s example his US theme’s theme.xml

<?xml version="1.0"?>
<theme>
    <parent>mycompany/corporate-base</parent>
    <layout>
        <updates>
            <us_default>
                <file>us/default.xml</file>
            </us_default>
        </updates>
    </layout>
</theme>

Could be changed to the following

<?xml version="1.0"?>
<theme>
    <parent>mycompany/corporate-base</parent>
    <layout>
        <updates>
            <us_default>
                <file>us/default.xml</file>
            </us_default>

            <corporate_base_default>
                <file>corporate-base/default.xml</file>
            </corporate_base_default>

        </updates>
    </layout>
</theme>

With this in place, his new theme would pickup the corporate-base updates. Notice we haven’t added corporate-base/default.xml to the US theme — all we’ve done is configure its name in theme.xml. The fallback system takes care of the rest.

If you’re curious why this works, my longer Magento 1.9 Infinite Theme Fallback article may be of interest.

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 21st May 2014

email hidden; JavaScript is required