Skip to main content
Handles the add portion of the attribute batch engine (createAndLinkProductAttributesToProductWorkflow). Existing text/unit attributes get a new value created from value; toggle links the seeded true/false value; existing variant-axis multi_select attributes have their mirror ProductOption attached to the product with the selected value subset. Inline refs create a product-scoped attribute — axis refs also create an exclusive ProductOption — and link the values to the product.

Usage

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

await addProductAttributesToProductWorkflow(container).run({
  input: {
    product_id: "prod_123",
    add: [
      { id: "pattr_material", value: "Cotton" },
      { title: "Size", values: ["S", "M", "L"], is_variant_axis: true },
    ],
  },
})
Also accepts an array of { product_id, add } items to process several products in one run.

Input

product_id
string
required
The product to attach the attributes to.
add
ProductAttributeBatchAdd[]
required
Attribute refs to attach.
additional_data
object
Custom data passed through.

Result

result
void
No return value.