1
0
Fork
You've already forked wpcli-product-attribute-tools
0
WooCommerce aware taxonomy manipulation utils (WIP)
  • PHP 100%
Find a file
2025年12月22日 19:28:47 +02:00
.gitignore LLM disclaimer 2025年11月27日 09:44:09 +02:00
admin-utils.php rename admin.php (collided with core) 2025年12月22日 19:28:10 +02:00
cmd-attribute-clean-empty.php rename cli to cmd 2025年12月22日 17:58:18 +02:00
cmd-attribute-merge.php documenting 2025年12月22日 19:28:22 +02:00
cmd-attribute-migrate.php show progress 2025年12月22日 19:28:47 +02:00
README.md notes about slug collision 2025年12月22日 19:27:53 +02:00
wpcli-product-attribute-tools.php rename admin.php (collided with core) 2025年12月22日 19:28:10 +02:00

WP-CLI product attribute tools for WooCommerce

Supports moving product attribute terms between taxonomies and merging attribute terms within taxonomy. Additionally shows term ids in admin for convenience.

Usage

Merge attribute (taxonomy term) with another:

wp wc attribute merge --by=slug --taxonomy=pa_product-color --term-from=83-gray --term-to=gray

Migrate attribute (taxonomy term) to another taxonomy:

wp wc attribute migrate --by=slug 83-gray --from=pa_color --to=pa_product-color

Migrating slugs existing on target taxonomy

Requires that target taxonomy doesn't have term with same slug. If slug is same in both source and target taxonomies, create a new term on old taxonomy side with different slug (manually), merge old one to that, and then migrate to target taxonomy.

wp term create <taxonomy> <temporary-term-name> --slug=<temporary-term-slug>
wp wc attribute merge --by=slug <duplicate-slug> --taxonomy=<source-taxonomy> --term-from=<source-term-name> --term-to=<temporary-term-slug>
wp wc attribute migrate --by=slug <temporary-term-slug> --from=<source-taxonomy> --to=<target-taxonomy>
wp wc attribute merge --by=slug --taxonomy=<target-taxonomy> --term-from=<temporary-term-slug> --term-to=<duplicate-slug>

Inspired by / credits

Loosely based on built-in wp term migrate (docs, source) which does not take into account the way WooCommerce product (and variation) attributes are connected to the WordPress taxonomy terms, leading to e.g. broken product variation data when used with product attributes.

LICENSE

BSD-3