Skip to content

feat(core-flows,product,types): scoped variant images#13623

Merged
olivermrbl merged 45 commits intodevelopfrom
feat/scoped-variant-images
Oct 26, 2025
Merged

feat(core-flows,product,types): scoped variant images#13623
olivermrbl merged 45 commits intodevelopfrom
feat/scoped-variant-images

Conversation

@fPolic
Copy link
Copy Markdown
Contributor

@fPolic fPolic commented Sep 29, 2025

What

This PR introduces the ability to associate product images with specific product variants, enabling more granular image management for products with multiple variants.

Scoped Image Management: Images can now be associated with specific variants instead of being global to the product
Bulk Operations: Batch add/remove variant associations for efficient management


API Changes

  • POST /admin/products/:id/variants/:variant_id/images/batch - Batch manage image associations for a variant
  • POST /admin/products/:id/images/:image_id/variants/batch - Batch manage variant associations for an image

Product Module Changes

  1. Data model:
  • ProductVariant model now includes images many-to-many relationship
  • ProductImage model now includes variants many-to-many relationship
  • ProductVariantProductImage pivot entity for managing associations
  • ProductVariant now has thumbnail
  1. Service methods:
  • addImageToVariant() - Associate images with specific variants
  • removeImageFromVariant() - Remove image-variant associations
  • getVariantImages() - Retrieve images for variants - (general product images + variant specific images)

Core Flows Changes

  • variant thumbnail will be used for the line item thumbnail if exists

CLOSES CORE-1214
CLOSES CORE-1215
CLOSES CORE-1216


Related PRs:

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
api-reference Building Building Preview Comment Oct 23, 2025 3:37pm
7 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
api-reference-v2 Ignored Ignored Preview Oct 23, 2025 3:37pm
cloud-docs Ignored Ignored Preview Oct 23, 2025 3:37pm
docs-ui Ignored Ignored Preview Oct 23, 2025 3:37pm
docs-v2 Ignored Ignored Preview Oct 23, 2025 3:37pm
medusa-docs Ignored Ignored Preview Oct 23, 2025 3:37pm
resources-docs Ignored Ignored Preview Oct 23, 2025 3:37pm
user-guide Ignored Ignored Preview Oct 23, 2025 3:37pm

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Sep 29, 2025

🦋 Changeset detected

Latest commit: 09838ef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 74 packages
Name Type
@medusajs/dashboard Patch
@medusajs/core-flows Patch
@medusajs/product Patch
@medusajs/js-sdk Patch
@medusajs/types Patch
@medusajs/medusa Patch
@medusajs/admin-bundler Patch
integration-tests-http Patch
@medusajs/draft-order Patch
@medusajs/framework Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/medusa-oas-cli Patch
@medusajs/test-utils Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/promotion Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/oas-github-ci Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/telemetry Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch
@medusajs/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@fPolic fPolic changed the title wip(product): variant images feat(core-flows,product,types): variant images Oct 2, 2025
@fPolic fPolic changed the title feat(core-flows,product,types): variant images feat(core-flows,product,types): scoped variant images Oct 2, 2025
Copy link
Copy Markdown
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, nice work

@cursor
Copy link
Copy Markdown

cursor bot commented Oct 21, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on November 17.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

* add: ["variant_123", "variant_456"]
* })
*/
export const addImageToVariantsStep = createStep(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we not make one step for both here? We have a step that adds one image to multiple variants and one that adds multiple images to one variant. Why not merge the 2 steps? We could pass a list of images and a list of variants and do it all in one go no?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or am I missing something? I feel like the remove scenario is similar too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, and what would behaviour be if we pass {images_ids: [i1,i2,i3], variant_ids: [v1,v2,v3]}? We add each image to each variant and delete combinations of image x variant for remove?

think this is one of those cases where a bit of duplication is ok for simpler, specific api, but no strong opinion

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is what I would imagine. No strong opinion either. I believe the customer/customer group duplicated. So leave it as is its fine:)

fPolic and others added 7 commits October 22, 2025 18:17
* wip(dashboard): setup variant media form

* wip: cleanup table and images, wip check handler

* feat: proper sidebar functionallity

* fefat: add js-sdk and hooks

* feat: allow only one selection

* wip: lazy load variants in the table

* feat: new variants management for images on product details

* chore: refactor

* wip: variant details page work

* fix: cleanup media section, fix issues and types

* feat: correct scoped images, cleanup in edit modal

* feat: js sdk and hooks, filter out product images on variant details, labels, add API call and wrap UI

* chore: cleanup

* refacto: rename route

* feat: thumbnail functionallity

* fix: refresh checked after revalidation load

* fix: rm unused, refactor type

* Create thirty-clocks-refuse.md

* feat: new add remove variant media layout

* feat: new image add UX

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants