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..

  • When you say overview page of products - is this a custom page or the products listing page? (grid/list view) – ash Apr 14 '15 at 10:37

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


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

echo $_helper->productAttribute($_product, $_product->getActiekorting(), 'actiekorting');
  • Yeah, your code worked! But a little syntax error this worked: 'actiekorting';) with the ) at the end :p – Mustafa Tosuncu Apr 14 '15 at 10:48
  • I have a small question, when setting this between a div, it won't output the value anymore. Any advice on styling these outputs? – Mustafa Tosuncu Apr 14 '15 at 10:57
  • PHP has no influence on the markup, if you "view source" on whatever browser you are using you can see if it is in fact being rendered but is hidden with CSS. – Adam Paterson Apr 15 '15 at 8:40
  • When I put a div class around it, you can see the class but there is no output. If I use the same kind of code as I did for my image, name attributes from the product page to this(costum homepage) page then I get the fatal error productAttributie on a non-object etc – Mustafa Tosuncu Apr 16 '15 at 9:16
  • <div><?php echo $_helper->productAttribute($_product, $_product->getActiekorting(), 'actiekorting');</div> should work if $_helper is defined before it. – Adam Paterson Apr 16 '15 at 11:24

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.