Skip to content

Commit

Permalink
Merge pull request #47 from aligent/fix/image_urls
Browse files Browse the repository at this point in the history
Handle empty image attributes
  • Loading branch information
aligent-lturner authored Nov 15, 2024
2 parents c8c14af + ec2c3c3 commit 8809af0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index/Model/Data/ImageFieldsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function getFields(array $productIds, $storeId): array
$result = [];
foreach ($products as $productId => $product) {
foreach ($this->imageAttributeConfig as $fredhopperAttribute => $imageConfig) {
$path = $product->getData($imageConfig['attribute_code']);
$path = (string)$product->getData($imageConfig['attribute_code']);

try {
$imageUrl = $this->getImageUrlForStore($imageConfig['display_area'], (int)$storeId, $path);
} catch (LocalizedException $e) {
Expand All @@ -87,6 +88,10 @@ public function getFields(array $productIds, $storeId): array
*/
private function getImageUrlForStore(string $imageDisplayArea, int $storeId, string $path): string
{
if (empty($path)) {
return '';
}

$this->emulation->startEnvironmentEmulation(
$storeId,
Area::AREA_FRONTEND,
Expand Down

0 comments on commit 8809af0

Please sign in to comment.