Automattic\WooCommerce\Internal\ProductAttributesLookup

DataRegenerator::run_woocommerce_installed_callback()privateWC 1.0

Run additional setup needed after a WooCommerce install or update finishes.

Method of the class: DataRegenerator{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->run_woocommerce_installed_callback();

DataRegenerator::run_woocommerce_installed_callback() code WC 9.3.3

private function run_woocommerce_installed_callback() {
	// The table must exist at this point (created via dbDelta), but we check just in case.
	if ( ! $this->data_store->check_lookup_table_exists() ) {
		return;
	}

	// If a table regeneration is in progress, leave it alone.
	if ( $this->data_store->regeneration_is_in_progress() ) {
		return;
	}

	// If the lookup table has data, or if it's empty because there are no products yet, we're good.
	// Otherwise (lookup table is empty but products exist) we need to initiate a regeneration if one isn't already in progress.
	if ( $this->data_store->lookup_table_has_data() || ! $this->get_last_existing_product_id() ) {
		$must_enable = get_option( 'woocommerce_attribute_lookup_enabled' ) !== 'no';
		$this->delete_all_attributes_lookup_data( false );
		update_option( 'woocommerce_attribute_lookup_enabled', $must_enable ? 'yes' : 'no' );
	} else {
		$this->initiate_regeneration();
	}
}