woocommerce / wc-smooth-generator

Smooth product, customer and order generation for WooCommerce
309 stars 49 forks source link

Products: Decouple from taxonomy term generation #119

Open coreymckrill opened 1 year ago

coreymckrill commented 1 year ago

Currently when generating products, each call to the generate method will in turn call the generate_term_ids method (twice, once for categories, once for tags), which may generate between 0 and 5 new taxonomy terms. That adds a lot of extra potential database queries, and can really slow down the product generation process.

There are a couple of different approaches we could take to mitigate this:

  1. Use the same strategy that the Orders generator takes. If there aren't any existing category and/or tag terms, just create products without them. If there are existing terms, randomly assign them as usual.
  2. Do create terms along with products, but create them all first, as a batch, and then randomly assign as usual.

I've already taken one step to address this issue with #117, so that term generation can be done as an entirely separate command before running generate products. The batch method in the Term class could also be used with approach 2 above.