Skip to main content
Replaces a product collection’s media. When media is provided, the entire existing gallery is swapped for the new list; when icon is provided, the existing icon image is swapped (pass null to clear it). Omitted fields are left untouched. At most one image keeps is_thumbnail and one keeps is_banner — the first flagged entry wins and later flags are silently dropped. Usually invoked through the createProductCollectionWithImagesWorkflow, updateProductCollectionWithImagesWorkflow, and deleteProductCollectionWithImagesWorkflow wrappers behind the /admin/collections routes.

Usage

import { setCollectionImagesWorkflow } from "@mercurjs/core/workflows"

await setCollectionImagesWorkflow(container).run({
  input: {
    collection_id: "pcol_123",
    media: [
      { url: "https://cdn.example.com/hero.jpg", is_banner: true },
      { url: "https://cdn.example.com/thumb.jpg", is_thumbnail: true },
    ],
    icon: "https://cdn.example.com/icon.svg",
  },
})

Input

collection_id
string
required
The collection whose images are replaced.
media
CollectionMediaInput[]
New gallery; replaces all existing non-icon images (pass [] to clear).
icon
string | null
New icon URL; null removes the current icon, omit to keep it.

Result

result
void
No return value.