Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show correct image on variants #1610

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions core/app/[locale]/(default)/product/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ export default async function Product({ params: { locale, slug }, searchParams }
: []),
];

const images = removeEdgesAndNodes(product.images).map((image) => ({
src: image.url,
alt: image.altText,
}));

const formattedProduct = {
id: product.entityId.toString(),
title: product.name,
href: product.path,
image: product.defaultImage && {
src: product.defaultImage.url,
alt: product.defaultImage.altText,
},
images: removeEdgesAndNodes(product.images).map((image) => ({
src: image.url,
alt: image.altText,
})),
images: product.defaultImage
? [{ src: product.defaultImage.url, alt: product.defaultImage.altText }, ...images]
: images,
price: pricesTransformer(product.prices, format),
subtitle: product.brand?.name,
rating: product.reviewSummary.averageRating,
Expand Down Expand Up @@ -329,14 +329,7 @@ export default async function Product({ params: { locale, slug }, searchParams }
<>
<ProductDetail action={addToCart} fields={formattedFields} product={formattedProduct} />

<ProductDescription
accordions={accordions}
image={{
src: product.defaultImage?.url ?? '',
alt: product.defaultImage?.altText ?? '',
}}
product={formattedProduct}
/>
<ProductDescription accordions={accordions} image={images[0]} product={formattedProduct} />

<ProductSchema product={product} />

Expand Down
Loading