cancel
Showing results for 
Search instead for 
Did you mean: 

How to get product attribute value from within Helper\Image or plugin

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

How to get product attribute value from within Helper\Image or plugin

I'm trying to customize Magento 2.0.2 CE to have Helper\Image getUrl() to return a custom url pointing to an external resource instead of using the Magento file system. I added a text attribute to the product that holds the image URL, but I can't find a way to access the value with either of the customization methods I've tried.

 

The first method was to override Magento\Catalog\Helper\Image and the getUrl() method. I can obtain the product from getProduct(), and I can find my attribute's object in the array returned from $product->getAttributes(), but I can't figure out how to get the actual value of the attribute from the Magento\Catalog\Model\ResourceModel\Eav\Atttribute\Interceptor object.

 

The second method was to create a plugin for Magento\Catalog\Helper\Image, but I can't figure out how to access the attribute value or even the product, since getProduct() is a protected method.

 

Any tips are much appreciated.