diff --git a/projects/core/src/occ/adapters/product/converters/product-image-normalizer.spec.ts b/projects/core/src/occ/adapters/product/converters/product-image-normalizer.spec.ts index 35f8214bdfc..3266997eb74 100644 --- a/projects/core/src/occ/adapters/product/converters/product-image-normalizer.spec.ts +++ b/projects/core/src/occ/adapters/product/converters/product-image-normalizer.spec.ts @@ -43,6 +43,13 @@ describe('ProductImageNormalizer', () => { imageType: ImageType.PRIMARY, url: 'https://hybris.com/test3.jpg', }, + { + altText: 'Test alt text', + format: 'cartIcon', + galleryIndex: null as any, + imageType: ImageType.PRIMARY, + url: '/test6', + }, { altText: 'Test alt text', format: 'product', @@ -83,6 +90,13 @@ describe('ProductImageNormalizer', () => { imageType: ImageType.PRIMARY, url: 'https://hybris.com/test3.jpg', }, + cartIcon: { + altText: 'Test alt text', + format: 'cartIcon', + galleryIndex: null as any, + imageType: ImageType.PRIMARY, + url: baseUrl + '/test6', + }, }, GALLERY: [ { diff --git a/projects/core/src/occ/adapters/product/converters/product-image-normalizer.ts b/projects/core/src/occ/adapters/product/converters/product-image-normalizer.ts index a80e80e29a1..58e2282ecc9 100644 --- a/projects/core/src/occ/adapters/product/converters/product-image-normalizer.ts +++ b/projects/core/src/occ/adapters/product/converters/product-image-normalizer.ts @@ -37,7 +37,7 @@ export class ProductImageNormalizer implements Converter { const images: Images = {}; if (source) { for (const image of source) { - const isList = image.hasOwnProperty('galleryIndex'); + const isList = this.hasGalleryIndex(image); if (image.imageType) { if (!images.hasOwnProperty(image.imageType)) { images[image.imageType] = isList ? [] : {}; @@ -98,4 +98,9 @@ export class ProductImageNormalizer implements Converter { '') + url ); } + + private hasGalleryIndex(image: Occ.Image) { + const galleryIndex = image.galleryIndex ?? false; + return galleryIndex !== false; + } }