Before you begin
You need the following:- A Mercur server: an API app with
@mercurjs/coreregistered throughwithMercur() - The concept: read Variant axes and product options to see how an axis maps to a Medusa
ProductOption
Build the axis and the product
1
Create the axis attribute
An axis is a Run it with
multi_select attribute with is_variant_axis: true. The workflow creates a global ProductOption titled Size with the same three values.src/scripts/seed-size-axis.ts
npx medusa exec ./src/scripts/seed-size-axis.ts. Medusa keeps global option titles unique, so a second global axis named Size fails.2
Create a product on the axis
Mercur’s Run this inside an authenticated route handler, so
createProductsWorkflow takes attributes and variants together. It attaches the axis with the values you pick, then creates the variants against it.req.auth_context.actor_id records who created the product. Each variant names its option value by the option title, which is the attribute name. The product only holds S and M, so those are the variants it can have.Change the values a product uses
RuncreateAndLinkProductAttributesToProductWorkflow with an update entry to grow or shrink the subset. The workflow moves the option values on the product and the pivot links together.
M and L. Create the L variant with Medusa’s createProductVariantsWorkflow and options: { Size: "L" }.
Create an axis for one product
When only one product needs a dimension, add an inline axis instead of a global one. It creates an exclusive option (is_exclusive: true), a product-scoped multi_select attribute, and its values, and attaches them to the product.
update and add: [{ value: "Relaxed" }].
Add values to a global axis
createProductAttributeValuesWorkflow adds values to the attribute and to its global option in one run. Products don’t gain the new value until you add it to their subset.