Skip to main content
Creates a pending ProductChange for one product, attaches the given actions to it, then runs autoConfirmProductChangeWorkflow — so the change is applied immediately when auto_confirm is true or the product_request feature flag is disabled. This is the engine behind the vendor product-edit workflows (productEditUpdateProduct, productEditUpdateVariants, productEditUpdateAttributes, productEditDeleteProduct). Emits product-change.created.

Usage

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

const { result } = await stageProductChangeWorkflow(container).run({
  input: {
    product_id: "prod_01H...",
    created_by: "sel_01H...",
    actions: [
      {
        product_id: "prod_01H...",
        action: "UPDATE",
        details: { title: "Linen Shirt v2" },
      },
    ],
  },
})

Input

product_id
string
required
Id of the product the change targets.
actions
object[]
required
Actions to stage on the change (CreateProductChangeActionDTO without product_change_id, which is stamped automatically).
created_by
string
Actor id who staged the change; also used as confirmed_by on auto-confirm.
internal_note
string
Operator-only note stored on the change.
external_note
string
Vendor-facing note stored on the change.
auto_confirm
boolean
Force immediate confirmation even when the product_request feature flag is enabled.

Result

result
ProductChangeDTO
The created change record; still pending unless it was auto-confirmed.