2

I'd change the default catalog/product/price.phtml

I've tried already:

<reference name="catalog_product_price_template">
     <action method="addPriceBlockType"><type>simple</type><block>catalog/product_price</block><template>catalog/product/custom-price.phtml</template></action>
</reference>

but using xdebug I've seen that the addPriceBlockType method is not used for the simple product, so it returns the default template.

where I'm wrong? thank you

2
  • Can you not copy the price template in to your own theme? It will look there first.
    – Smartie
    Commented Sep 9, 2015 at 11:20
  • sorry, I was not clear, the template should be replace just for a custom handle product type
    – apedic
    Commented Sep 9, 2015 at 11:23

1 Answer 1

2

My actual solution is to rewrite the class Mage_Catalog_Block_Product_View_Type_Simple

class Store_Core_Block_Catalog_Product_View_Type_Simple extends Mage_Catalog_Block_Product_View_Type_Simple{
    protected $_priceBlockDefaultTemplate = 'catalog/product/custom-price.phtml';

    protected function _getPriceBlockTemplate($productTypeId)
    {
        if (isset($this->_priceBlockTypes[$productTypeId])) {
            if ($this->_priceBlockTypes[$productTypeId]['template'] != '') {
                return $this->_priceBlockTypes[$productTypeId]['template'];
            }
        }
        return $this->_priceBlockDefaultTemplate;
    }
}

I can now use some logic to choose the correct price template based on product type. However, I'm wondering if there is any other solution just using xml layouts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.