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

  • Can you not copy the price template in to your own theme? It will look there first. – Smartie Sep 9 '15 at 11:20
  • sorry, I was not clear, the template should be replace just for a custom handle product type – Antonio Pedicini Sep 9 '15 at 11:23
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, privacy policy and cookie policy

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