Skip to content

Commit

Permalink
Use variation when selecting image
Browse files Browse the repository at this point in the history
  • Loading branch information
gvc committed Feb 29, 2024
1 parent 05e8651 commit 2939f4e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/api/src/platforms/vtex/utils/skuVariants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ export function getFormattedVariations(
return
}

const variantImageToUse = findSkuVariantImage(variant.images)

const dominantVariantEntry = variant.variations.find(
(variation) => variation.name === dominantVariantName
)
Expand All @@ -179,6 +177,8 @@ export function getFormattedVariations(

previouslySeenPropertyValues.add(nameValueIdentifier)

const variantImageToUse = findSkuVariantImage(variant.images, dominantVariantName)

const formattedVariant = {
src: variantImageToUse.imageUrl,
alt: variantImageToUse.imageLabel ?? '',
Expand All @@ -204,6 +204,8 @@ export function getFormattedVariations(

previouslySeenPropertyValues.add(nameValueIdentifier)

const variantImageToUse = findSkuVariantImage(variant.images, variationProperty.name)

const formattedVariant = {
src: variantImageToUse.imageUrl,
alt: variantImageToUse.imageText ?? '',
Expand Down

0 comments on commit 2939f4e

Please sign in to comment.