diff --git a/.changeset/lemon-news-give.md b/.changeset/lemon-news-give.md new file mode 100644 index 000000000..def19b027 --- /dev/null +++ b/.changeset/lemon-news-give.md @@ -0,0 +1,5 @@ +--- +"products-feed": minor +--- + +Product feed: prioritize media assigned to a specific product variant. with a fallback mechanism to use product media when no variant-specific media is available. The changes aim to enhance the precision of media selection diff --git a/apps/products-feed/src/modules/google-feed/get-related-media.ts b/apps/products-feed/src/modules/google-feed/get-related-media.ts index 781220f84..c99166f6b 100644 --- a/apps/products-feed/src/modules/google-feed/get-related-media.ts +++ b/apps/products-feed/src/modules/google-feed/get-related-media.ts @@ -23,15 +23,14 @@ export const getRelatedMedia = ({ variantMediaMap, productMedia, }: getRelatedMediaArgs) => { - // Saleor always uses the first photo as thumbnail - even if it's assigned to the variant - const productThumbnailUrl = productMedia[0]?.url; - const mediaAssignedToAnyVariant = Object.values(variantMediaMap).flat() || []; const mediaAssignedToNoVariant = productMedia?.filter((m) => !mediaAssignedToAnyVariant.find((vm) => vm.id === m.id)) || []; const mediaAssignedToVariant = variantMediaMap[productVariantId] || []; + // Saleor always uses the first photo as thumbnail - even if it's assigned to the variant + const productThumbnailUrl = mediaAssignedToVariant[0]?.url || productMedia[0]?.url; const additionalImages = [...mediaAssignedToVariant, ...mediaAssignedToNoVariant]