Magento: Change the block template in local.xml

Magento: Change the block template in local.xml

October 1, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: Change the block template in local.xml

Changing Magento Block Templates: A Guide

As an experienced developer, you might find yourself needing to modify or override existing block templates in your Magento store for more custom functionality.

The default product review page uses the catalog/product/view.phtml template file to display all the content on the page. However, there may be instances where you want to use a different layout for this specific page.

Understanding the Default Configuration

Let’s first break down how the default configuration works:

In your theme directory, navigate to the app/design/frontend/packagename/theme/Magento_Theme/layout/review.xml file. Here is what you’ll find:

<block type="review/product_view" name="product.info" template="catalog/product/view.phtml">
    <action method="setProductId"><product_id><![CDATA[{$block.getProduct().getId()}]]></product_id></action>
</block>

This code tells Magento to use the view.phtml file located in the app/design/frontend/packagename/theme/Magento_Theme/templates/catalog/product directory for displaying product information.

Overriding Templates in Local.xml

To override this template and create a new one, follow these steps:

  1. In your theme directory (app/design/frontend/packagename/theme), navigate to the layout folder.
  2. Create a new XML file named local.xml.
  3. Open this new file and add the following code:
<layout version="0.1.0">
    <default>
        <reference name="product.info" template="catalog/product/view2.phtml"/>
    </default>
</layout>
  1. Create a new directory structure: app/design/frontend/packagename/theme/Magento_Theme/templates/catalog/product
  2. Inside this new directory, create your custom template file named view2.phtml and add your desired HTML content.
<?php
    /* @var $this Mage_Core_Block_Template */
?>
<div class="product-custom">
    <div class="custom-content">This is my custom review page with a different layout.</div>
</div>

Things to Consider

Remember, when overriding templates in Magento, the changes will only apply to your current theme.

To make these changes permanent, ensure that you’re using version control systems like Git and back up your work regularly. This helps you revert any unwanted changes quickly.

Conclusion: Template Overrides Made Easy

In this post, we demonstrated how to override the default product review template in Magento using local.xml configuration files. By following this method, you can create custom templates for specific pages while keeping your core files intact.

For a more detailed guide on theme development and overriding in Magento 2, please refer to our comprehensive resource at https://laravelcompany.com/magento-theme-development-guide/.

Happy coding! Don’t hesitate to reach out if you have any other questions about Magento development or e-commerce solutions.

Catalog Themes Configuration

Our network