Categories


Archives


Recent Posts


Categories


Your local.xml Layout File Might not Win

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!

When explaining the local.xml Layout file, you’ll hear Magento veterans (myself included) explain that local.xml is loaded last, so the updates there always “win”.

This is true, to an extent, but there’s one big caveat to keep in mind. Layout Update XML Fragments are loaded and applied in order, by handle. That means all the <default/> update fragments, including those in local.xml, will be applied before any others, so something like this in local.xml

<default>
    <reference name="category.products">
        <block type="some/block" name="adding_a_block"/>
    </reference>
</default>

won’t work. That’s because the block you’re trying to reference (category.products) doesn’t exist yet. It’s not added to the layout until the handle catalog_category_default runs.

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 24th June 2011

email hidden; JavaScript is required