Skip to content

Commit 949b3da

Browse files
ENGCOM-7517: Product not exist fix when attempt to get an image #26877
2 parents 19be4ce + 0cdc6b7 commit 949b3da

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/code/Magento/Catalog/Helper/Image.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ public function backgroundColor($colorRGB)
384384
{
385385
// assume that 3 params were given instead of array
386386
if (!is_array($colorRGB)) {
387+
//phpcs:disable
387388
$colorRGB = func_get_args();
389+
//phpcs:enabled
388390
}
389391
$this->_getModel()->setBackgroundColor($colorRGB);
390392
return $this;
@@ -498,7 +500,11 @@ protected function initBaseFile()
498500
if ($this->getImageFile()) {
499501
$model->setBaseFile($this->getImageFile());
500502
} else {
501-
$model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir()));
503+
$model->setBaseFile(
504+
$this->getProduct()
505+
? $this->getProduct()->getData($model->getDestinationSubdir())
506+
: ''
507+
);
502508
}
503509
}
504510
return $this;

app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,14 @@ public function testGetWidth()
396396
$this->assertEquals($data['width'], $this->helper->getWidth());
397397
}
398398

399+
/**
400+
* Check initBaseFile without properties - product
401+
*/
402+
public function testGetUrlWithOutProduct()
403+
{
404+
$this->assertNull($this->helper->getUrl());
405+
}
406+
399407
/**
400408
* @param array $data
401409
* @dataProvider getHeightDataProvider

0 commit comments

Comments
 (0)