Fix ‘Call to a Member Function productAttribute() on a Non-Object’ Error

fatal error

I have set a new custom attribute called actiekorting with a value of 25% on a product. It shows perfectly in detailed product page. But when I'm trying to copy the same line on a different page (overview page of products) I get the following fatal error: Call to a member function productAttribute() on a non-object in etc..

Best Answer

This is happening because the class this method belongs to hasn't been instantiated.

Make sure the object you're trying to call productAttribute() on is an instance of Mage_Catalog_Helper_Output

Example

$_helper = Mage::helper('catalog/output');

echo $_helper->productAttribute($_product, $_product->getActiekorting(), 'actiekorting');
Related Topic