createOffersWorkflow when you onboard a store’s catalog or run an import. One run creates every offer or none of them.
Before you begin
You need these records in place:- A store and a member: the
seller_idand thecreated_bymember id for every entry - Master variants: one
variant_idper row you import - A shipping profile and a stock location: both owned by the store
Import a store’s rows
1
Map your rows to offer entries
Turn each source row into a Each entry is independent and carries its own SKU, price, and starting stock.
CreateOfferDTO from @mercurjs/types.src/lib/to-offers.ts
2
Run the workflow once for the batch
Call the workflow with the mapped entries.The run emits one
src/api/admin/custom/offers/import/route.ts
offer.created event per offer.The batch is all or nothing. A missing variant, an entry without inventory items, or a SKU the store already uses fails the run, and compensation removes everything it created.
Update offers in bulk
updateOffersWorkflow takes the same array shape, keyed by offer id. Every field except id is optional.
id to update a row in place, since rows left out are deleted. updated_by reaches the offersUpdated and offerPricesUpserted hooks.
Delete offers in bulk
deleteOffersWorkflow takes a list of ids and soft-deletes the offer rows.
offer.deleted per offer. Its offersDeleted hook gets a snapshot of each offer and its prices taken before the delete. The workflow has no step that removes the offer’s prices or inventory items.