WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта
функция не описана

Automattic\WooCommerce\Internal\ProductAttributesLookup

LookupDataStore::create_lookup_table_entries_for_variable_product() private WC 1.0

Create lookup table entries for a variable product. Assumes that no entries exist yet.

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

Хуков нет.

Возвращает

null. Ничего.

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

// private - только в коде основоного (родительского) класса
$result = $this->create_lookup_table_entries_for_variable_product( $product );
$product(WC_Product_Variable) (обязательный)
The product to create the entries for.

Код LookupDataStore::create_lookup_table_entries_for_variable_product() WC 5.5.2

<?php
private function create_lookup_table_entries_for_variable_product( \WC_Product_Variable $product ) {
	$product_attributes_data       = $this->get_attribute_taxonomies( $product );
	$variation_attributes_data     = array_filter(
		$product_attributes_data,
		function( $item ) {
			return $item['used_for_variations'];
		}
	);
	$non_variation_attributes_data = array_filter(
		$product_attributes_data,
		function( $item ) {
			return ! $item['used_for_variations'];
		}
	);

	$main_product_has_stock = $product->is_in_stock();
	$main_product_id        = $product->get_id();

	foreach ( $non_variation_attributes_data as $taxonomy => $data ) {
		$term_ids = $data['term_ids'];
		foreach ( $term_ids as $term_id ) {
			$this->insert_lookup_table_data( $main_product_id, $main_product_id, $taxonomy, $term_id, false, $main_product_has_stock );
		}
	}

	$term_ids_by_slug_cache = $this->get_term_ids_by_slug_cache( array_keys( $variation_attributes_data ) );
	$variations             = $this->get_variations_of( $product );

	foreach ( $variation_attributes_data as $taxonomy => $data ) {
		foreach ( $variations as $variation ) {
			$variation_id                 = $variation->get_id();
			$variation_has_stock          = $variation->is_in_stock();
			$variation_definition_term_id = $this->get_variation_definition_term_id( $variation, $taxonomy, $term_ids_by_slug_cache );
			if ( $variation_definition_term_id ) {
				$this->insert_lookup_table_data( $variation_id, $main_product_id, $taxonomy, $variation_definition_term_id, true, $variation_has_stock );
			} else {
				$term_ids_for_taxonomy = $data['term_ids'];
				foreach ( $term_ids_for_taxonomy as $term_id ) {
					$this->insert_lookup_table_data( $variation_id, $main_product_id, $taxonomy, $term_id, true, $variation_has_stock );
				}
			}
		}
	}
}