Automattic\WooCommerce\Internal\ProductAttributesLookup
LookupDataStore::create_data_for_product
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.
If a product id is passed and it no longer resolves to a product, any stale lookup data for that id is removed and the operation is not considered failed (see 'get_last_create_operation_failed'). Product objects are used as-is.
Метод класса: 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() LookupDataStore::create data for product WC 11.3.0
public function create_data_for_product( $product, $use_optimized_db_access = false ) {
$product_id = intval( ( $product instanceof \WC_Product ) ? $product->get_id() : $product );
if ( $use_optimized_db_access ) {
$this->create_data_for_product_cpt( $product_id );
} else {
if ( ! $product instanceof \WC_Product ) {
$product = WC()->call_function( 'wc_get_product', $product );
}
// A product can be deleted after its lookup table update has been scheduled.
if ( ! $product ) {
$this->delete_data_for( $product_id );
$this->last_create_operation_failed = false;
return;
}
$this->delete_data_for( $product->get_id() );
$this->create_data_for( $product );
}
}