Magento Custom Module – How to Use getPriceHtml() in Custom PHTML

phtmlprice

I have a custom module with custom phtml which will print the product. But it seems that, the below code

$this->getPriceHtml($_product, true);

won't render any thing on that page. So I tried to change my code to

$product_block = new Mage_Catalog_Block_Product;
echo $product_block->getPriceHtml($_product, true);

But it generated an error message like this.

Call to a member function getStoreLabel() on a non-object in lines XX

How can i fix this problem?

Best Answer

hkinterview,

custom phtml block class should need to extends Mage_Catalog_Block_Product_Abstract

then  `$this->getPriceHtml($_product, true);` will be workss 

example

class YoumoduleNamespace_yourModuleName_Block_yourclass extends Mage_Catalog_Block_Product_Abstract