Skip to content

Commit

Permalink
MAGETWO-70391: Return URL in getThumbnailUrl instead of nothing #10106
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Korshenko authored Jun 30, 2017
2 parents 98f3fea + bbbc9fe commit 1b3587f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 9 additions & 3 deletions app/code/Magento/Catalog/Helper/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,18 @@ public function getSmallImageUrl($product)
* Retrieve thumbnail image url
*
* @param ModelProduct|\Magento\Framework\DataObject $product
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @return string|bool
*/
public function getThumbnailUrl($product)
{
return '';
$url = false;
$attribute = $product->getResource()->getAttribute('thumbnail');
if (!$product->getThumbnail()) {
$url = $this->_assetRepo->getUrl('Magento_Catalog::images/product/placeholder/thumbnail.jpg');
} elseif ($attribute) {
$url = $attribute->getFrontend()->getUrl($product);
}
return $url;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ public function testGetSmallImageUrl()

public function testGetThumbnailUrl()
{
$this->assertEmpty(
$this->helper->getThumbnailUrl(
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Catalog\Model\Product::class
)
)
/** @var $product \Magento\Catalog\Model\Product */
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Catalog\Model\Product::class
);
$this->assertStringEndsWith('placeholder/thumbnail.jpg', $this->helper->getThumbnailUrl($product));
$product->setThumbnail('test_image.png');
$this->assertStringEndsWith('/test_image.png', $this->helper->getThumbnailUrl($product));
}

public function testGetEmailToFriendUrl()
Expand Down

0 comments on commit 1b3587f

Please sign in to comment.