Today I will share with you one of the most interesting things I have experienced when working with Magento platform. It’s how to add a block to the product page without modifying the template. I know sometimes you want to show the specific information on the product page such as questions about the product, user guide document, etc. Normally, you open the template file (catalog/product/view.phtml), and then insert some code to this file. However, it it’s really unstable if you change your Magento theme. By taking the following steps, you can absolutely avoid this problem:

1. Open the layout file of your module.

2. Insert the piece of code below to your layout file.

<catalog_product_view>
<reference name="product.info.extrahint">
<block type="Module_Name/Block_Name" template="Module_Name/Template_File_Name.phtml"/>
</reference>
</catalog_product_view>

Please note that you need to replace Module_Name, Block_Name and Template_File_Name with the specific values. Now take a look at the screenshot below to see how your block will be shown:

There are many other useful tips for Magento that I want to share with you. We will gradually discover them in my next posts, OK? Also, if you have any ideas, don’t hesitate to leave comments here. See you again!

Related Tutorials:

Author

Alex is the CTO & Co-founder of Magestore which has been providing retail solutions for Magento merchants since 2009. He started as a Magento developer just one year after the release of the first version of Magento. With over 10 years experience of working with Magento and clients all over the world, he gained great knowledge on e-commerce development, order management systems, inventory control & retail POS.

Write A Comment