Products: Decouple taxonomy term generation #156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed in this Pull Request:
Makes it so that the products generator only assigns existing category and tag terms to new products, instead of generating them on the fly. In some rudimentary testing, this improved the performance of the products generator by about 9%.
This also introduces a new class for caching reusable data at runtime,
RandomRuntimeCache
. In this PR it is used so that we only need to query category and tag taxonomy terms once each instead of with every new product. However, the class has several other potential uses which could be implemented in separate PRs.Fixes #119
How to test the changes in this Pull Request:
wp wc generate products
. This should generate 10 products. Go view the products on the Products list table. None of them should have categories or tags assigned to them (except the "Uncategorized" category).wp wc generate terms product_cat
andwp wc generate terms product_tag
. Go to their respective screens in WP Admin so you can see that they have been created.wp wc generate products
. This time the products should have some of the existing categories and tags assigned to them, though there is also the random chance for each product that it will get assigned0
terms for categories and/or tags.Changelog entry