Elevate Web Cardiff

Using $this->getPriceHtml in custom phtml file

getPriceHtml($product);

//if inside a loop than unset the instance.
unset($product_block);
?>

However in magento 1.8 this stopped working and now you need to make an edit to a core file to stop the error
Fatal error: Call to a member function getStoreLabel() on a non-object

Just open \app\design\frontend\base\default\template\catalog\product\price.phtml

and change

$_specialPriceStoreLabel = $this->getProductAttribute(‘special_price’)->getStoreLabel();
to

$specialPriceAttr = $this->getProductAttribute(‘special_price’);
if (!is_null($specialPriceAttr)) {
$_specialPriceStoreLabel = $specialPriceAttr->getStoreLabel();
} else {
$_specialPriceStoreLabel = ”;
}

Everything should work now just fine

Share this post


Warning: count(): Parameter must be an array or an object that implements Countable in /domains/elevateweb.co.uk/http/pub/wp-includes/class-wp-comment-query.php on line 405
  • kostadinbg

    You are not actually fixing the root problem.
    The fact that special_price attribute is not loaded(accessible) in this block, means that special price will not be displayed even if the product has 🙂