MagenMarket How to fix Fatal error: Call to a member function getStoreLabel() in price.phtml / MagenMarket.com News, Tutorials and Blog

How to fix Fatal error: Call to a member function getStoreLabel() in price.phtml

Play with Magento 1.8 CE and some one may get this fatal error:

Fatal error: Call to a member function getStoreLabel() on a non-object in /app/design/frontend/.../.../template/catalog/product/price.phtml

This is not happen with Magento 1.7 CE! We are not sure if it is Magento's bug but a "quick and dirty" fix may help you.

Solution

Step 1:

Open file /app/design/frontend/<PACKAGE>/<THEME>/template/catalog/product/price.phtml to edit.

If it is not there, just copy /app/design/frontend/base/default/template/catalog/product/price.phtml to /app/design/frontend/<PACKAGE>/<THEME>/template/catalog/product/

Step 2: Find this code:

$_specialPriceStoreLabel = $this->getProductAttribute('special_price')->getStoreLabel();

And change it to:

//$_specialPriceStoreLabel = $this->getProductAttribute('special_price')->getStoreLabel();
$_specialPriceStoreLabel = '';
if ($this->getProductAttribute('special_price')) $_specialPriceStoreLabel = $this->getProductAttribute('special_price')->getStoreLabel();

Save the file, clear Magento cache and try it!