I'm writing a custom extension and trying to override the price.phtml
template (catalog/product/price.phtml
) with my own but I cannot get it to work.
The documentation and examples I have seen suggest I should use the addPriceBlockType
method in the layout update xml file as shown below. However, this doesn't work and it is driving me mad.
Other layout updates work so I know the layout xml file is being called correctly from the module's config.xml
.
One thing - I think in older versions of Magento there was different product price template files for each of the product types but this is no longer the case in 1.7? Could that mean that addPriceBlockType
will no longer work and I need to use some other method?
Any help would be much appreciated.
Thanks! Chris
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="catalog_product_price_template">
<action method="addPriceBlockType"><type>simple</type><block>catalog/product_price</block><template>hideprice/price.phtml</template></action>
<action method="addPriceBlockType"><type>grouped</type><block>catalog/product_price</block><template>hideprice/price.phtml</template></action>
<action method="addPriceBlockType"><type>configurable</type><block>catalog/product_price</block><template>hideprice/price.phtml</template></action>
<action method="addPriceBlockType"><type>virtual</type><block>catalog/product_price</block><template>hideprice/price.phtml</template></action>
<action method="addPriceBlockType"><type>bundled</type><block>catalog/product_price</block><template>hideprice/price.phtml</template></action>
</reference>
</default>
...
Update: Thanks to Marius below for shedding some light on this. I have now found another approach which to me is much cleaner than messing round with the insanely complicated xml layouts.
In my module I have extended Mage_Catalog_Block_Product_Price
and added a call to
$this->setTemplate('hideprice/price.phtml')
in the _toHtml()
function. This single change ensures that my new price.phtml
template is used everywhere.