WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Internal\ProductAttributesLookup

DataRegenerator::initialize_table_and_data() private WC 1.0

Create the lookup table and initialize the options that will be temporarily used while the regeneration is in progress.

{} It's a method of the class: DataRegenerator{}

No Hooks.

Return

true|false. True if there's any product at all in the database, false otherwise.

Usage

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

Code of DataRegenerator::initialize_table_and_data() WC 5.9.0

private function initialize_table_and_data() {
	global $wpdb;

	// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
	$wpdb->query(
		'
CREATE TABLE ' . $this->lookup_table_name . '(
  product_id bigint(20) NOT NULL,
  product_or_parent_id bigint(20) NOT NULL,
  taxonomy varchar(32) NOT NULL,
  term_id bigint(20) NOT NULL,
  is_variation_attribute tinyint(1) NOT NULL,
  in_stock tinyint(1) NOT NULL
 );
	'
	);
	// phpcs:enable WordPress.DB.PreparedSQL.NotPrepared

	$last_existing_product_id =
		WC()->call_function(
			'wc_get_products',
			array(
				'return'  => 'ids',
				'limit'   => 1,
				'orderby' => array(
					'ID' => 'DESC',
				),
			)
		);

	if ( ! $last_existing_product_id ) {
		// No products exist, nothing to (re)generate.
		return false;
	}

	$this->data_store->set_regeneration_in_progress_flag();
	update_option( 'woocommerce_attribute_lookup_last_product_id_to_process', current( $last_existing_product_id ) );
	update_option( 'woocommerce_attribute_lookup_last_products_page_processed', 0 );

	return true;
}