Organize product categories in bulk

WooCommerceIntermediate~25 minUpdated

Before you start

A connected store with the WooCommerce integration enabled and the term read, create and update abilities and the product update ability turned on. Add post terms is refused on WooCommerce products unless the site owner has exposed the Product content type, so products are moved with Update product, which takes category IDs and replaces the product's whole category list. The agent reads each product's current categories first and sends the full list it should end up with. The product list shows category IDs only, so the agent matches names to IDs using the category list.

Product categories grow by accident. A “Misc” bucket fills up, two categories end up meaning the same thing, and the tree that made sense at fifty products is a mess at five hundred. Tidying it in the admin means clicking through the categories screen and editing products one by one.

This lets the agent read the current tree, lay your reorganization out beside it, and make the moves once you approve. Reparenting is guarded so a category can never become its own ancestor, and each product ends up with exactly the category list you approved.

The prompt
I want to reorganize the product categories in my store. Here is the change I
want: [rename "Misc" to "Accessories", move "Hats" and "Scarves" under a new
"Winter" parent, and put the products tagged [X] into "Winter"]. Do not change
anything yet.
First, list the current product categories with the number of products in
each, and show me the new tree beside the current one plus the exact list of
products that would move. Flag anything that would create a loop, like making
a category its own parent.
Once I approve, create and rename the categories, then move the named products
in batches of [20], and pause between batches. Moving a product replaces its
whole category list, so for each product read its current categories first and
send the full list it should end up with, using category IDs, and show me that
final list in the plan. Do not use the post-terms tool for products, it is
refused on them unless the Product content type is exposed. At the end, list every category you created or renamed and
every product you reassigned, with its before and after categories.

Why this is safe to run

The first pass is a read. Listing the categories and their product counts changes nothing, so you approve a before-and-after tree rather than reshape live data blind. Any reparenting is checked against a circular-hierarchy guard, so an approved move can never leave a category pointing at itself as its own parent.

The product move needs care, and the plan is where it is handled. Update product replaces a product’s category list rather than adding to it, so the agent reads the current list first and shows you each product’s before and after, and a product only ends up with the categories you approved. Renaming and reparenting edit a category in place. There is no delete in this recipe at all: clearing an old category is a deliberate, separate step you take yourself. The term and product abilities stay off until you enable them, every write is checked against the capability of the bound user, and each change is recorded in the Activity Log.

Already connected? Skip the paste. Ask your agent for the “organize product categories in bulk” recipe, or just describe the tree you want, and it runs the same read-then-approve flow on your own store.

How it works

  1. List the current product categories and how many products each holds.
  2. Lay out the change you describe: renames, reparenting, new categories, and which products move where.
  3. Show the before-and-after tree and the product moves, and wait for your approval.
  4. Create and rename the approved categories, then read each named product's current categories and set its full new category list in small batches.
  5. Report every category created or renamed and every product reassigned.

Questions

Does it remove a product from its old category when it adds a new one?
Only if you say so. Update product replaces the whole category list, so the agent reads each product's current categories and sends the full list it should end up with, and the plan you approve shows that final list per product. To add a category and keep the old ones, the list keeps them; for a clean move, the list leaves the old one out.
Can it delete a category?
No. This recipe only lists, creates, renames, and reparents categories and sets the categories on products. There is no delete-term ability in the toolset, so deleting an empty category is a step you take in WooCommerce.