WooCommerce aware taxonomy manipulation utils (WIP)
- PHP 100%
| .gitignore | LLM disclaimer | |
| admin-utils.php | rename admin.php (collided with core) | |
| cmd-attribute-clean-empty.php | rename cli to cmd | |
| cmd-attribute-merge.php | documenting | |
| cmd-attribute-migrate.php | show progress | |
| README.md | notes about slug collision | |
| wpcli-product-attribute-tools.php | rename admin.php (collided with core) | |
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