Bulk-add a size or color variation across a category

WooCommerceAdvanced~30 minUpdated

Before you start

A connected store with the WooCommerce integration enabled and its attribute and variation abilities turned on. The target products must already be variable products that already declare the value you are adding (for example XL under Size). A variation can only use a value its parent product declares, and the tools cannot add a value to a global attribute or declare a global attribute on a product, so a missing value on a global attribute has to be added in WooCommerce first. The product list shows category IDs only, so the agent matches your category name to its ID from the product category terms.

You added an XL to the range, or a new color, and now it needs to exist on every product in a category. One at a time that means opening each variable product, going to the Variations tab, adding the row, setting a price, and saving, over and over.

This recipe adds one variation across a whole category at once. It works on products that are already set up as variable and already use the attribute, so it is filling in a gap rather than rebuilding the product. You confirm the exact list before it creates anything.

The prompt
I want to add a [size XL] variation across [the "T-Shirts" category]. These
are already variable products that use the [Size] attribute. Do not create
anything yet.
First, list the products in that category, and read each one's existing
variations so you can leave out any that already have [XL]. Check that each
product already declares [XL] under [Size]. A variation can only use a value its
product declares, and you cannot add a value to a global attribute or declare a
new global attribute on a product, so for any product that is missing [XL],
list it for me to fix in WooCommerce and leave it out. Then show me the exact
list of products you would add an [XL] variation to, and wait for my approval.
Once I approve, create the [XL] variation on each approved product in batches
of [15], setting the price and SKU I give you, and pause between batches. At
the end, list every variation you created with its product.

Why this is safe to run

Nothing is created before your approval. Listing the products in the category and reading each one’s attributes and variations are reads, so the only decision point is a list of products you sign off on by name. Because you confirm that list, a product you do not want touched, or one that already has the value, simply stays off it.

The only writes are new variations on products you named, so nothing existing is overwritten. The attribute and its values are not touched: if a value is missing, the product is listed for you to fix in WooCommerce. The variation ability is off until you turn it on, every create is gated on the manage-WooCommerce capability, and each new variation is recorded in the Activity Log with its parent product.

Already connected? You do not have to paste this. Ask your agent for the “bulk-add a variation across a category” recipe, or just name the category and the value, and it runs the same confirm-then-create flow on your own store.

How it works

  1. List the products in the category you name so you can confirm which ones should get the new variation.
  2. Read each product's existing variations and leave out any that already have the value.
  3. Check that each product already declares the value you want, and list any that do not for you to add in WooCommerce.
  4. Show the exact list of products that would get the new variation and wait for your approval.
  5. Create the approved variations in small batches, pausing between them.
  6. Report every variation it created with its product and value.

Questions

Will this convert simple products into variable ones?
No. It adds a variation to products that are already variable and already declare that attribute value. You confirm the target products in the preview, and anything else is left alone.
What if a product already has that size or color?
The agent reads each product's existing variations and leaves out any that already have the value, so no duplicate is created. You still approve the final list before anything is written.