File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed
app/code/Magento/Catalog/Helper
dev/tests/integration/testsuite/Magento/Catalog/Helper Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -251,12 +251,18 @@ public function getSmallImageUrl($product)
251251 * Retrieve thumbnail image url
252252 *
253253 * @param ModelProduct|\Magento\Framework\DataObject $product
254- * @return string
255- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
254+ * @return string|bool
256255 */
257256 public function getThumbnailUrl ($ product )
258257 {
259- return '' ;
258+ $ url = false ;
259+ $ attribute = $ product ->getResource ()->getAttribute ('thumbnail ' );
260+ if (!$ product ->getThumbnail ()) {
261+ $ url = $ this ->_assetRepo ->getUrl ('Magento_Catalog::images/product/placeholder/thumbnail.jpg ' );
262+ } elseif ($ attribute ) {
263+ $ url = $ attribute ->getFrontend ()->getUrl ($ product );
264+ }
265+ return $ url ;
260266 }
261267
262268 /**
Original file line number Diff line number Diff line change @@ -90,13 +90,13 @@ public function testGetSmallImageUrl()
9090
9191 public function testGetThumbnailUrl ()
9292 {
93- $ this ->assertEmpty (
94- $ this ->helper ->getThumbnailUrl (
95- \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
96- \Magento \Catalog \Model \Product::class
97- )
98- )
93+ /** @var $product \Magento\Catalog\Model\Product */
94+ $ product = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
95+ \Magento \Catalog \Model \Product::class
9996 );
97+ $ this ->assertStringEndsWith ('placeholder/thumbnail.jpg ' , $ this ->helper ->getThumbnailUrl ($ product ));
98+ $ product ->setThumbnail ('test_image.png ' );
99+ $ this ->assertStringEndsWith ('/test_image.png ' , $ this ->helper ->getThumbnailUrl ($ product ));
100100 }
101101
102102 public function testGetEmailToFriendUrl ()
You can’t perform that action at this time.
0 commit comments