Skip to main content
deleted 267 characters in body
Source Link
Rajeev K Tomy
  • 17.3k
  • 6
  • 63
  • 103

Another way is rewrite this class. But it is better than the above method. But rewriting a class should always avoid, if we have another alternatives.

Actually there exists another alternative and it is the right method to do this. Magento will allow us to set custom template depends upon the product type. We are going to do this via layout update. So for this, I assume you are using CMS page for your home page. In that case,

So the actual solution is, you need to use this xml update in your cms page itself. But if you didn't do it properly there, it wont work again. But if you have good knowledge on magento layout update, then this is the best method that you can adopt and I highly recommend it.

If the layout updation didn't work, then you really need to go for rewrite the catalog-produt-abstract class.

Another way is rewrite this class. But it is better than the above method. But rewriting a class should always avoid, if we have another alternatives.

Actually there exists another alternative and it is the right method to do this. Magento will allow us to set custom template depends upon the product type. We are going to do this via layout update. So for this, I assume you are using CMS page for your home page. In that case,

So the actual solution is, you need to use this xml update in your cms page itself. But if you didn't do it properly there, it wont work again. But if you have good knowledge on magento layout update, then this is the best method that you can adopt and I highly recommend it.

If the layout updation didn't work, then you really need to go for rewrite the catalog-produt-abstract class.

Actually there exists another alternative and it is the right method to do this. Magento will allow us to set custom template depends upon the product type. We are going to do this via layout update. So for this, I assume you are using CMS page for your home page. In that case,

So the actual solution is, you need to use this xml update in your cms page itself. But if you didn't do it properly there, it wont work again. But if you have good knowledge on magento layout update, then this is the best method that you can adopt and I highly recommend it.

Source Link
Rajeev K Tomy
  • 17.3k
  • 6
  • 63
  • 103

Price block is hardly coded in Magento core. By default magento uses catalog/product/price.phtml file to render it's content. This block is actually set through Mage_Catalog_Block_Product_Abstract class. So the easy way would be change the following line in that class.

File : app\code\core\Mage\Catalog\Block\Product\Abstract.php

 protected $_priceBlockDefaultTemplate = 'path/to/your/custom/price.phtml';

But changing the core code is not recommended. So I am not promoting this direct change.

Another way is rewrite this class. But it is better than the above method. But rewriting a class should always avoid, if we have another alternatives.

Actually there exists another alternative and it is the right method to do this. Magento will allow us to set custom template depends upon the product type. We are going to do this via layout update. So for this, I assume you are using CMS page for your home page. In that case,

File : app/design/frontend/<your_package>/<your_theme>/layout/local.xml

<layout>
    <cms_index_index>
        <reference name="product_list">
            <action method="addPriceBlockType">
                <type>simple</type>
                <block>catalog/product_price</block>
                <template>path/to/your/custom/price.phtml</template>
            </action>
            <action method="addPriceBlockType">
                <type>bundle</type>
                <block>catalog/product_price</block>
                <template>path/to/your/custom/price.phtml</template>
            </action>
            <action method="addPriceBlockType">
                <type>configurable</type>
                <block>catalog/product_price</block>
                <template>path/to/your/custom/price.phtml</template>
            </action>
            <action method="addPriceBlockType">
                <type>grouped</type>
                <block>catalog/product_price</block>
                <template>path/to/your/custom/price.phtml</template>
            </action>
            <action method="addPriceBlockType">
                <type>virtual</type>
                <block>catalog/product_price</block>
                <template>path/to/your/custom/price.phtml</template>
            </action>
            <action method="addPriceBlockType">
                <type>downloadable</type>
                <block>catalog/product_price</block>
                <template>path/to/your/custom/price.phtml</template>
            </action>
        </reference>
    </cms_index_index>
</layout>

As you can see, here we are setting custom template for all product type.

But this probably will not work. :) That is because, in order to work this code, it is required that, you need to define product_list block before this file get processed. Most probably you have added featured product via admin and those layout update will process after this file process. Hence it will not work.

So the actual solution is, you need to use this xml update in your cms page itself. But if you didn't do it properly there, it wont work again. But if you have good knowledge on magento layout update, then this is the best method that you can adopt and I highly recommend it.

If the layout updation didn't work, then you really need to go for rewrite the catalog-produt-abstract class.