Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Products: Decouple taxonomy term generation #156

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

coreymckrill
Copy link
Contributor

@coreymckrill coreymckrill commented Jan 2, 2025

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:

  1. Start with a new test site with no products, product categories, or product tags.
  2. Run 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).
  3. Now generate some categories and tags. wp wc generate terms product_cat and wp wc generate terms product_tag. Go to their respective screens in WP Admin so you can see that they have been created.
  4. Now generate some more products, 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 assigned 0 terms for categories and/or tags.

Changelog entry

De-couple taxonomy term generation from product generation.

@coreymckrill coreymckrill self-assigned this Jan 2, 2025
@coreymckrill coreymckrill changed the title Fix/119/product term decouple Products: Decouple taxonomy term generation Jan 3, 2025
@coreymckrill coreymckrill marked this pull request as ready for review January 3, 2025 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Products: Decouple from taxonomy term generation
1 participant