The action record
AProductChangeAction (id prefix prodchact) belongs to a parent change through product_change_id and targets a product_id. Its action field names the operation, and its details JSON holds the payload. The applied boolean starts false and flips to true once the action has been written to the product.
Actions also carry an auto-incrementing ordering, plus reference and reference_id columns. Mercur’s workflows don’t set the reference columns, so you can use them to point an action at a record of your own.
stageProductChangeWorkflow in its actions array. ProductChangeActionType is exported from @mercurjs/types.
Action types
Theaction field takes one of the 11 ProductChangeActionType values. The edit workflows also store the previous value in details, so a reviewer can see the before and after:
PRODUCT_ADD and CHANGE_REQUESTED only appear on audit changes, which Mercur stores with applied: true. See The change pipeline.
What the edit workflows diff
The edit workflows stage an action only when your input differs from the product. Arrays of relations compare by id or URL, ignoring order, so resending the same categories stages nothing:- Product fields:
title,subtitle,handle,description,discountable,is_giftcard,thumbnail,images,material,weight,length,height,width,hs_code,mid_code,origin_country,type_id,collection_id,categories,tags,sales_channels,metadata - Status: a
statuskey in the update becomes aSTATUS_CHANGEaction instead of anUPDATE - Variants:
manage_inventoryis skipped on update, andimagestakes{ add, remove }image ids - Attributes: an add the product already holds, or a remove of an attribute it doesn’t hold, stages nothing
productEditUpdateProductWorkflow.
How actions apply
When a change is confirmed,applyProductChangeActionsWorkflow loads its actions with applied: false, groups them by type, and runs each group once. The groups run in this order:
STATUS_CHANGEandUPDATE, merged per product into oneupdateProductsWorkflowcallVARIANT_REMOVEthroughdeleteProductVariantsWorkflowVARIANT_ADDthroughcreateProductVariantsWorkflowVARIANT_UPDATEscalar fields throughupdateProductVariantsWorkflow, then the variant image linksATTRIBUTE_*as one batch throughcreateAndLinkProductAttributesToProductWorkflowPRODUCT_DELETEthroughdeleteProductsWorkflow, followed bydeleteOffersWorkflowfor the product’s offers
applied: true, so running the apply workflow again on the same change never writes an action twice. Types it doesn’t handle, PRODUCT_ADD and CHANGE_REQUESTED, keep whatever applied value they were stored with.