JavaScript
import Medusa from "@medusajs/js-sdk" export const sdk = new Medusa({ baseUrl: import.meta.env.VITE_BACKEND_URL || "/", debug: import.meta.env.DEV, auth: { type: "session", }, }) sdk.admin.product.batchImageVariants("prod_123", "img_123", { add: ["variant_123", "variant_456"], remove: ["variant_789"] }) .then(({ added, removed }) => { console.log(added, removed) })
200
Example
{ "added": [ "<string>" ], "removed": [ "<string>" ] }
Manage the association between product variants and a product image. You can add or remove associations between variants and the image.
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Bearer <token>
<token>
The product's ID.
The product image's ID.
Details of the associations between variants and a product image to manage.
The IDs of product variants to add the image to.
The ID of the variant to add.
The IDs of product variants to remove the image from.
The ID of the variant to remove.
OK
Result of managing the associations between variants and a product image.
The IDs of product variants added the image to.
The ID of the variant added.
The IDs of product variants removed the image from.
The ID of the variant removed.