Skip to content

Commit 8809af0

Browse files
Merge pull request #47 from aligent/fix/image_urls
Handle empty image attributes
2 parents c8c14af + ec2c3c3 commit 8809af0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/index/Model/Data/ImageFieldsProvider.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public function getFields(array $productIds, $storeId): array
6262
$result = [];
6363
foreach ($products as $productId => $product) {
6464
foreach ($this->imageAttributeConfig as $fredhopperAttribute => $imageConfig) {
65-
$path = $product->getData($imageConfig['attribute_code']);
65+
$path = (string)$product->getData($imageConfig['attribute_code']);
66+
6667
try {
6768
$imageUrl = $this->getImageUrlForStore($imageConfig['display_area'], (int)$storeId, $path);
6869
} catch (LocalizedException $e) {
@@ -87,6 +88,10 @@ public function getFields(array $productIds, $storeId): array
8788
*/
8889
private function getImageUrlForStore(string $imageDisplayArea, int $storeId, string $path): string
8990
{
91+
if (empty($path)) {
92+
return '';
93+
}
94+
9095
$this->emulation->startEnvironmentEmulation(
9196
$storeId,
9297
Area::AREA_FRONTEND,

0 commit comments

Comments
 (0)