cancel
Showing results for 
Search instead for 
Did you mean: 

Product Attribute not available in widget

Product Attribute not available in widget

Hi,

I created some product-attributes like 'Softwaresystem' 

When I use 

<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getSoftwaresystem(), 'softwaresystem') ?>

in /catalog/list.phtml it shows me the correct value in product listing view of each product.

 

The same expression in /catalogWidget/product/widget/content/grid.phtml 

leads to this error:

Fehler beim Filtern der Vorlage: Notice: Undefined variable: _helper in /XXX//Magento_CatalogWidget/templates/product/widget/content/grid.phtml on line 66

 

Anyone an idea or alternative? thank you!

2 REPLIES 2

Re: Product Attribute not available in widget

Everything you need to solve your problem is in the error message! Smiley Happy

Fehler beim Filtern der Vorlage: Notice: Undefined variable: _helper in

When you say $_helper->productAttribute, you're calling a method on the object inside the $_helper variable. At the top of product/list.phtml (which I assume you meant, since Magento 2 doesn't ship with a catalog/list.phtml) you'll see the following code.

#File: vendor/magento/module-catalog/view/frontend/templates/product/list.phtml

$_helper = $this->helper('Magento\Catalog\Helper\Output');

That's where $_helper gets defined.

However, in grid.phtml

#File: vendor/magento//module-backend/view/adminhtml/templates/widget/grid.phtml

There's no such $_helper variable defined. I'd start by trying to define that helper at the top of grid.phtml

$_helper = $this->helper('Magento\Catalog\Helper\Output');

However, there's also no $_product defined in grid.phtml either, so you'll need to get a reference to a product object somehow. I assume you have that handled, or if you don't you'll provide folks with enough context about what you're doing so they'll be able to help.

Good luck!

Re: Product Attribute not available in widget

Thank you for this detailed feedback! I'll try ...