Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

5.6 KB
Raw Blame
---
title: "Product edits"
sidebarTitle: "Overview"
description: "Review every seller edit to a shared product before it lands, and keep a record of who changed what."
---

Use Mercur to put seller edits to the shared catalog through review, and to keep a durable history of every change to a product.

Products in Mercur form one shared catalog that every seller sells against, so a seller can’t write to a product directly. Each edit becomes a `ProductChange` record that holds typed actions, one per changed field, variant, or attribute. The change waits as `pending` until an operator confirms or declines it, or its author cancels it. Confirmed changes, together with publish approvals, rejections, and revision requests, form the product’s audit trail.

<img className="block dark:hidden" src="/images/figures/product-edit-overview-light.svg" alt="A product's Changes list read through product.changes: a pending UPDATE from the seller sits on top of confirmed PRODUCT_ADD, CHANGE_REQUESTED, UPDATE, and STATUS_CHANGE records that form the audit trail." />
<img className="hidden dark:block" src="/images/figures/product-edit-overview-dark.svg" alt="A product's Changes list read through product.changes: a pending UPDATE from the seller sits on top of confirmed PRODUCT_ADD, CHANGE_REQUESTED, UPDATE, and STATUS_CHANGE records that form the audit trail." />

<Note>
  The Product Edit module (`MercurModules.PRODUCT_EDIT`) governs changes to a product. It never makes a store the owner of one. Products live in Medusa’s Product module, and sellers sell them through [offers](/platform/offer/overview).
</Note>

## How it works

A seller edit moves through the pipeline in five steps:

1. A vendor route runs an edit workflow such as `productEditUpdateProductWorkflow`, which diffs the input against the product and stages a `pending` change with one action per difference.
2. `autoConfirmProductChangeWorkflow` runs right after staging. With the `product_request` feature flag on, the default, the change stays `pending`.
3. An operator confirms or declines the change, or the seller cancels it.
4. On confirm, `applyProductChangeActionsWorkflow` writes the actions to the product through Medusa’s product workflows and marks each action `applied`.
5. Product creation, publish approvals, rejections, and revision requests are recorded as changes that start out `confirmed`, so the trail is complete without a review.

## Key features

The module covers the full path of an edit, from diff to audit record:

- **Field-level diffs**: the edit workflows stage only the fields, variants, and attributes that differ from the current product
- **Typed actions**: each change holds `ProductChangeAction` rows such as `UPDATE`, `VARIANT_ADD`, `ATTRIBUTE_UPDATE`, or `PRODUCT_DELETE`
- **Review queue**: a change moves from `pending` to `confirmed`, `declined`, or `canceled`, each through its own workflow and event
- **Deferred writes**: actions touch the product only when the change is confirmed
- **Auto-confirm**: turn off the `product_request` flag, or pass `auto_confirm`, to apply a change in the same run
- **Revision requests**: an operator sends a proposed product back to its seller with a recorded `CHANGE_REQUESTED` action
- **One open change per author**: the edit workflows reject a new change while the same author has one pending on the product

## Get started

Learn how changes, actions, and statuses fit together.

<CardGroup cols={2}>
  <Card title="The change pipeline" icon="clock-rotate-left" href="/platform/product-edit/concepts/change-pipeline">
    How an edit becomes a `ProductChange` and how the audit trail builds up.
  </Card>
  <Card title="Change actions" icon="list-check" href="/platform/product-edit/concepts/change-actions">
    The action types, the `details` each one carries, and how they apply.
  </Card>
  <Card title="Status & auto-confirm" icon="arrows-rotate" href="/platform/product-edit/concepts/status-and-auto-confirm">
    The status lifecycle, revision requests, and when a change skips review.
  </Card>
</CardGroup>

## Examples

Build against the change pipeline in your own server code.

<CardGroup cols={2}>
  <Card title="Edit a product" icon="pen" href="/platform/product-edit/guides/edit-a-product">
    Stage field, variant, and attribute changes from a custom route.
  </Card>
  <Card title="Confirm or decline" icon="gavel" href="/platform/product-edit/guides/confirm-or-decline-a-change">
    Resolve a pending change and react to the result.
  </Card>
  <Card title="Request a revision" icon="rotate-left" href="/platform/product-edit/guides/request-a-revision">
    Send a proposed product back to its seller with a message.
  </Card>
</CardGroup>

## Resources

The data models, links, workflows, service methods, and events behind product edits.

<CardGroup cols={2}>
  <Card title="Data models" icon="table" href="/platform/product-edit/reference/data-models">
    The `ProductChange` and `ProductChangeAction` models and their enums.
  </Card>
  <Card title="Links" icon="link" href="/platform/product-edit/reference/links">
    The read-only `product.changes` link to Medusa’s Product module.
  </Card>
  <Card title="Workflows" icon="diagram-project" href="/platform/product-edit/reference/workflows">
    Staging, resolution, apply, edit, and audit workflows with their hooks.
  </Card>
  <Card title="Service" icon="gear" href="/platform/product-edit/reference/service">
    Generated methods on the Product Edit module service.
  </Card>
  <Card title="Events" icon="bell" href="/platform/product-edit/reference/events">
    The `product-change.*` events and the revision request event.
  </Card>
</CardGroup>