Automattic\WooCommerce\Internal\ProductAttributesLookup

LookupDataStore::create_data_for_product()publicWC 1.0

Create the lookup data for a given product, if a variable product is passed the information is created for all of its variations. This method is intended to be called from the data regenerator.

Метод класса: LookupDataStore{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$LookupDataStore = new LookupDataStore();
$LookupDataStore->create_data_for_product( $product, $use_optimized_db_access );
$product(int|WC_Product) (обязательный)
Product object or id.
$use_optimized_db_access(true|false)
Use direct database access for data retrieval if possible.
По умолчанию: false

Код LookupDataStore::create_data_for_product() WC 9.3.3

public function create_data_for_product( $product, $use_optimized_db_access = false ) {
	if ( $use_optimized_db_access ) {
		$product_id = intval( ( $product instanceof \WC_Product ) ? $product->get_id() : $product );
		$this->create_data_for_product_cpt( $product_id );
	} else {
		if ( ! is_a( $product, \WC_Product::class ) ) {
			$product = WC()->call_function( 'wc_get_product', $product );
		}

		$this->delete_data_for( $product->get_id() );
		$this->create_data_for( $product );
	}
}