> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mercurjs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# updateProductAttributesOnProductWorkflow

> Mutate a product's per-attribute value selections.

Handles the `update` portion of the attribute batch engine (`createAndLinkProductAttributesToProductWorkflow`). For shared axis attributes it adjusts the per-product value subset of the mirror option and keeps the value-link pivot in sync; for exclusive (product-scoped) axis attributes it creates or deletes values on the exclusive option; for `text`/`unit` it swaps the linked value's name (or creates one); for `toggle` it re-links the matching `true`/`false` value. A `title` on a product-scoped attribute renames it via `updateProductAttributesWorkflow`.

## Usage

```ts theme={null}
import { updateProductAttributesOnProductWorkflow } from "@mercurjs/core/workflows"

await updateProductAttributesOnProductWorkflow(container).run({
  input: {
    product_id: "prod_123",
    update: [
      { id: "pattr_size", add: ["pattrval_xl"], remove: ["pattrval_s"] },
      { id: "pattr_material", value: "Linen" },
    ],
  },
})
```

## Input

<ParamField body="product_id" type="string" required>The product whose attribute selections are updated.</ParamField>

<ParamField body="update" type="ProductAttributeBatchUpdate[]" required>
  Per-attribute updates.

  <Expandable title="properties">
    <ParamField body="id" type="string" required>Id of the existing attribute to update.</ParamField>
    <ParamField body="title" type="string">New name; only honoured for product-scoped attributes and propagated to the mirror option title.</ParamField>
    <ParamField body="add" type="(string | { value: string })[]">Value ids to add (shared axis subset) or new value objects to create (exclusive axis).</ParamField>
    <ParamField body="remove" type="string[]">Value ids to remove from the selection (exclusive-axis values are deleted).</ParamField>
    <ParamField body="value" type="string | number | boolean">New scalar for `text` / `unit` / `toggle` attributes.</ParamField>
  </Expandable>
</ParamField>

<ParamField body="additional_data" type="object">Custom data passed through.</ParamField>

## Result

<ResponseField name="result" type="void">No return value.</ResponseField>
