Skip to main content
Creates values on an existing attribute. If the attribute is a variant-axis multi_select with a mirror ProductOption, the option’s value list is extended first and each new attribute value is bound to its option value via product_option_value_id. Triggered by POST /admin/product-attributes/:id/values. Emits product-attribute-value.created.

Usage

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

const { result } = await createProductAttributeValuesWorkflow(container).run({
  input: {
    attribute_id: "pattr_color",
    values: [{ name: "Green" }, { name: "Yellow", rank: 5 }],
  },
})

Input

attribute_id
string
required
The attribute to add the values to.
values
CreateProductAttributeValueDTO[]
required
Values to create.
additional_data
object
Custom data passed through to the hooks.

Result

result
ProductAttributeValueDTO[]
The created values.

Hooks

  • validate — runs before creation with { input }.
  • productAttributeValuesCreated — runs after creation with { values, additional_data }.