Skip to main content
Updates product attributes by selector. When name changes, the mirror ProductOption title of any affected axis attribute is updated to match. Triggered by POST /admin/product-attributes/:id. Emits product-attribute.updated.

Usage

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

const { result } = await updateProductAttributesWorkflow(container).run({
  input: {
    selector: { id: "pattr_123" },
    update: { name: "Colour", is_filterable: true },
  },
})

Input

selector
object
required
Filter for the attributes to update, e.g. { id: "pattr_123" }.
update
UpdateProductAttributeDTO
required
Fields to set on every matched attribute.
additional_data
object
Custom data passed through to the hooks.

Result

result
ProductAttributeDTO[]
The updated attributes.

Hooks

  • validate — runs before the update with { input }.
  • productAttributesUpdated — runs after the update with { attributes, additional_data }.