Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product not exist fix when attempt to get an image #26877

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/code/Magento/Catalog/Helper/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ public function backgroundColor($colorRGB)
{
// assume that 3 params were given instead of array
if (!is_array($colorRGB)) {
//phpcs:disable
$colorRGB = func_get_args();
//phpcs:enabled
}
$this->_getModel()->setBackgroundColor($colorRGB);
return $this;
Expand Down Expand Up @@ -498,7 +500,11 @@ protected function initBaseFile()
if ($this->getImageFile()) {
$model->setBaseFile($this->getImageFile());
} else {
$model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir()));
$model->setBaseFile(
$this->getProduct()
? $this->getProduct()->getData($model->getDestinationSubdir())
: ''
);
}
}
return $this;
Expand Down
8 changes: 8 additions & 0 deletions app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@ public function testGetWidth()
$this->assertEquals($data['width'], $this->helper->getWidth());
}

/**
* Check initBaseFile without properties - product
*/
public function testGetUrlWithOutProduct()
{
$this->assertNull($this->helper->getUrl());
}

/**
* @param array $data
* @dataProvider getHeightDataProvider
Expand Down