0

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

1
  • When you say overview page of products - is this a custom page or the products listing page? (grid/list view)
    – Ash
    Commented Apr 14, 2015 at 10:37

1 Answer 1

0

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');
9
  • Yeah, your code worked! But a little syntax error this worked: 'actiekorting';) with the ) at the end :p Commented Apr 14, 2015 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? Commented Apr 14, 2015 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. Commented Apr 15, 2015 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 Commented Apr 16, 2015 at 9:16
  • <div><?php echo $_helper->productAttribute($_product, $_product->getActiekorting(), 'actiekorting');</div> should work if $_helper is defined before it. Commented Apr 16, 2015 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.