Inicio - Documentación - POM AI - 17 MCP - WooCommerce product tools - `wc_set_product_attributes`: assign product attributes

wc_set_product_attributes: assign product attributes

Sets which attributes a product declares, and which of them drive its variations.

Arguments

Argument Required Meaning
product_id Yes The product
attributes Yes The complete list of attributes for this product
dry_run No Report without writing

Each entry in attributes takes:

Key Meaning
name The attribute; entries without it are skipped
options The values this product offers
visible Show it in the product's information table
variation Use it to build variations

The response is the full product.

Permissions

Allow WooCommerce catalog writes open, plus manage_woocommerce or edit_products.

It replaces the whole set

This is the critical behaviour. The list you pass becomes the product's attributes — anything currently on the product and absent from your list is removed.

Adding one attribute therefore means sending all of them:

Read product 219's current attributes, then set them again with Material added. Show me the full list before writing.

Sending a single-entry list to "add Material" deletes Size and Colour. On a variable product, that severs every variation from the combination it represents, and the whole product stops being purchasable.

Read first. Always send the complete intended set.

visible and variation are independent

  • visible controls whether customers see the attribute in the product's information table. Presentation only.
  • variation controls whether the attribute can be used to build variations. Structural.

An attribute with variation off cannot appear in a variation's attributes map — or rather, it can, and the variation will simply never be selectable. This is the most common reason a correctly-created variation does not show up.

Turning variation off on an attribute an existing variation depends on breaks that variation the same way.

Entries missing name vanish silently

Any entry that is malformed, or that omits name, is dropped. No error, and the response reports the attributes that were saved — not the ones you sent.

So an assistant can send five attributes, have one silently dropped, and report success. Compare the response against your intended list every time.

options are the values for this product

They are a subset of what the attribute offers: the shop may define eight sizes while this product stocks three.

For global attributes, use the term slugs exactly as wc_get_attribute_terms reports them. Values that do not match an existing term are stored, and produce combinations that resolve to nothing.

An empty options on an attribute flagged for variations gives a product with no combinations to build from.

The order of operations

  1. wc_get_product — the current attributes, so you can preserve them.
  2. wc_get_product_attributes and wc_get_attribute_terms — the exact names and slugs.
  3. This tool — the complete set, with variation on where needed.
  4. wc_create_variation — one per combination.

Doing step 3 after step 4 is what breaks working products.

The dry run

Echoes back the attributes you supplied, unprocessed. It confirms what the tool received — useful for catching a malformed entry before it is silently dropped — but it does not show you what the product currently has.

That means it is not a before/after. Get the "before" yourself, from the product read.

On a live variable product

Changing attributes on a product that is already selling is high risk: it can strand variations, empty the selector and change the price range, immediately and publicly.

Do it on staging first, or during quiet hours with the previous attribute set written down.

After writing

  1. Compare the returned attributes against your intended list, entry by entry.
  2. List the variations and confirm none were stranded.
  3. Open the product page and select a combination end to end.
  4. Check the information table shows what you expect.
  5. Purge the cache, then the CDN.

Common problems

Symptom Cause
The write is refused Catalog write gate closed
pom_ai_mcp_wc_product_not_found Wrong ID
pom_ai_mcp_wc_forbidden Missing shop capability
Attributes disappeared The list replaces; they were omitted
The response is missing an attribute you sent That entry had no name
Variations became unselectable variation is off, or the options changed
The product cannot be added to a cart Its variations no longer match any combination
The information table looks wrong visible flags

Related