Versions: spree_core 5.6.1, spree_storefront 5.4.6
Spree::ProductsHelper#product_media_gallery_images builds the gallery from selected_variant.images, the legacy variant-pinned association. Since 5.5, per-variant media is stored as product-level assets linked through spree_variant_media and exposed as Variant#gallery_media / #associated_media. For products using the new model, variant.images is empty, so the helper falls through to product.primary_media and every variant renders the same image. Selecting a different variant on the PDP never changes the gallery.
Expected: the gallery follows the selected variant, as Variant#gallery_media already resolves both storage models.
Separately, this line in the same method is dead code:
images = selected_variant&.images&.to_a || []
images ||= variant_from_options&.images&.to_a if images.empty?
images is [] at that point, which is truthy, so ||= never assigns and variant_from_options media is never used.
Reproduce: create a product with two variants, upload two images at product level, link one to each variant, then switch variants on the PDP.
Versions: spree_core 5.6.1, spree_storefront 5.4.6
Spree::ProductsHelper#product_media_gallery_imagesbuilds the gallery fromselected_variant.images, the legacy variant-pinned association. Since 5.5, per-variant media is stored as product-level assets linked throughspree_variant_mediaand exposed asVariant#gallery_media/#associated_media. For products using the new model,variant.imagesis empty, so the helper falls through toproduct.primary_mediaand every variant renders the same image. Selecting a different variant on the PDP never changes the gallery.Expected: the gallery follows the selected variant, as
Variant#gallery_mediaalready resolves both storage models.Separately, this line in the same method is dead code:
images is [] at that point, which is truthy, so ||= never assigns and
variant_from_optionsmedia is never used.Reproduce: create a product with two variants, upload two images at product level, link one to each variant, then switch variants on the PDP.