PHP Magento Tips

Powered by Blogger.

Insert Core Template File Into Product View Page Before Price in magento

Rate this posting:

To add Core Template File Into Product View Page which is most important page for your end user, follow below steps:

In your local.xml file add below code:

for simple product type:

<?xml version="1.0"?>



        <reference name="">

            <block type="core/template" name="test" template="test.phtml" before="-"/>




You can target different Product Types and their Layout Handles as per below:
Product type Layout update handle
Simple PRODUCT_TYPE_simple
Configurable PRODUCT_TYPE_configurable
Grouped PRODUCT_TYPE_grouped
Virtual PRODUCT_TYPE_virtual
Downloadable PRODUCT_TYPE_downloadable
Bundle PRODUCT_TYPE_bundle
and for all types of products you can write:

<?xml version="1.0"?>
        <reference name="alert.urls">
            <block type="core/template" name="test" template="test.phtml" after="-"/>

You can change the position of the block by simply changing the before after node.
After that create file in app/design/frontend/rwd/default/template/test/test.phtml and add below code in it.

    $product = Mage::registry('current_product');
    if ($product) {
        $id = $product->getId();
    else {
        //it means you are not in a product page
        $id = null;
with above code you will get product ID of current product and with

$obj = Mage::getModel('catalog/product')->load($id);

you can get all the information of that product.
Tag : Magento
0 Comments On "Insert Core Template File Into Product View Page Before Price in magento"

Back To Top