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 );
$product(int|WC_Product) (обязательный)
Product object or id.

Код LookupDataStore::create_data_for_product() WC 8.7.0

public function create_data_for_product( $product ) {
	if ( ! is_a( $product, \WC_Product::class ) ) {
		$product = WC()->call_function( 'wc_get_product', $product );
	}

	if ( $this->is_variation( $product ) ) {
		throw new \Exception( "LookupDataStore::create_data_for_product can't be called for variations." );
	}

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