public function testGetImageUrl() { /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product'); $this->assertStringEndsWith('placeholder/image.jpg', $this->_helper->getImageUrl($product)); $product->setImage('test_image.png'); $this->assertStringEndsWith('/test_image.png', $this->_helper->getImageUrl($product)); }
/** * Set current attribute to entry (for specified product) * * @param \Magento\Catalog\Model\Product $product * @param \Magento\Framework\Gdata\Gshopping\Entry $entry * @return \Magento\Framework\Gdata\Gshopping\Entry */ public function convertAttribute($product, $entry) { $url = $this->_catalogProduct->getImageUrl($product); if ($product->getImage() && $product->getImage() != 'no_selection' && $url) { $this->_setAttribute($entry, 'image_link', self::ATTRIBUTE_TYPE_URL, $url); } return $entry; }
/** * Render grid row * * @param \Magento\Framework\DataObject $row * @return string */ public function render(\Magento\Framework\DataObject $row) { $imageUrl = $row->getImage() && $row->getImage() != 'no_selection' ? $this->escapeHtml($this->_productHelper->getImageUrl($row)) : ''; return $this->_getValue($row) . '<input type="hidden" data-role="image-url" value="' . $imageUrl . '"/>'; }