Automattic\WooCommerce\Internal\CLI\Migrator\Platforms\Webflow

WebflowFetcher::ensure_category_cache_loaded │ private │ WC 1.0

Ensures the category cache has been resolved at most once per fetcher instance.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->ensure_category_cache_loaded( $site_id ): void;
$site_id(строка) (обязательный)
Webflow site ID.

Код WebflowFetcher::ensure_category_cache_loaded() WC 11.2.2

private function ensure_category_cache_loaded( string $site_id ): void {
	if ( null !== $this->category_cache ) {
		return;
	}

	$this->category_cache = array();

	$collections_response = $this->webflow_client->rest_request( "/sites/{$site_id}/collections" );
	if ( is_wp_error( $collections_response ) ) {
		// @phpstan-ignore-next-line class.notFound
		\WP_CLI::debug( 'Could not load Webflow collections list (categories will not be resolved): ' . $collections_response->get_error_message() );
		return;
	}

	$collections = $this->extract_collections_list( $collections_response );
	$category_id = $this->find_category_collection_id( $collections );

	if ( null === $category_id ) {
		// @phpstan-ignore-next-line class.notFound
		\WP_CLI::debug( 'No "category" collection found on Webflow site; product categories will be skipped.' );
		return;
	}

	$this->category_cache = $this->load_collection_items_map( $category_id );
}