Template Overrides With Magento

by: Preston Schmidt

Magento template Override Basics

Sometimes with Magento you need to make changes to the template files to configure and/or construct your site to your specific needs and application. Luckily it's a fairly straight forward process when it comes to this, just as long as you follow some basic rules. Magento core site files reside under the folder named "app" in any Magento site, and under this folder is stored your "code", "design", "etc", and "locale" folders. It's in the latter "locale" folder where we are able to utilize template overrides in the true Magento fashion.

In this example we will use the recurring profiles and billing agreement files of a Magento install. These particular files reside in this directory location: app/design/frontend/base/default/layout/sales/, and the file names are billing_agreement.xml and recurring_profile.xml.

So the file paths will be:

  • app/design/frontend/base/default/layout/sales/billing_agreement.xml
  • app/design/frontend/base/default/layout/sales/recurring_profiles.xml

Now, it is the "locale" folder that resides under the "app" folder that allows us to do template overrides in Magento. Magento will always look in our locale folder first to see what kind of content we have in there, if it finds anything, it will use this instead of the default files. The trick is that you don't just put the edited file in the locale folder, but that you must mimic the folder structure as well. So with our billing_agreement file, we would need to place it under the same folders it is by default, only substituting the "design" folder with the "local" folder. So the new path would look like this:

  • app/locale/frontend/base/default/layout/sales/billing_agreement.xml

And that's the way of template overrides in Magento, so easy! This is the proper method for editing core files, and makes it much easier to revert back to original file states, as well as being able to do Magento updates without over-writing all your changes.


Video, Web, and Design Agency