DataRegenerator
This class handles the (re)generation of the product attributes lookup table.
Description Description
It schedules the regeneration in small product batches by itself, so it can be used outside the regular WooCommerce data regenerations mechanism.
After the regeneration is completed a wp_wc_product_attributes_lookup table will exist with entries for all the products that existed when initiate_regeneration was invoked; entries for products created after that are supposed to be created/updated by the appropriate data store classes (or by the code that uses the data store classes) whenever a product is created/updated.
Additionally, after the regeneration is completed a ‘woocommerce_attribute_lookup__enabled’ option with a value of ‘no’ will have been created.
This class also adds two entries to the Status – Tools menu: one for manually regenerating the table contents, and another one for enabling or disabling the actual lookup table usage.
Source Source
File: src/Internal/ProductAttributesLookup/DataRegenerator.php
Methods Methods
- __construct — DataRegenerator constructor.
- add_initiate_regeneration_entry_to_tools_array — Add a 'Regenerate product attributes lookup table' entry to the Status - Tools page.
- delete_all_attributes_lookup_data — Delete all the existing data related to the lookup table, including the table itself.
- do_regeneration_step — Perform one regeneration step: grabs a chunk of products and creates the appropriate entries for them in the lookup table.
- enable_or_disable_lookup_table_usage — Enable or disable the actual lookup table usage.
- enqueue_regeneration_step_run — Enqueue one regeneration step in action scheduler.
- finalize_regeneration — Cleanup/final option setup after the regeneration has been completed.
- init — Class initialization, invoked by the DI container.
- initialize_table_and_data — Create the lookup table and initialize the options that will be temporarily used while the regeneration is in progress.
- initiate_regeneration — Initialize the regeneration procedure: deletes the lookup table and related options if they exist, then it creates the table and runs the first step of the regeneration process.
- initiate_regeneration_from_tools_page — Callback to initiate the regeneration process from the Status - Tools page.
- lookup_table_exists — Check if the lookup table exists in the database.
- regeneration_is_in_progress — Tells if a regeneration is already in progress.
- run_regeneration_step_callback — Action scheduler callback, performs one regeneration step and then schedules the next step if necessary.