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

WebflowFetcher::find_category_collection_id │ private │ WC 1.0

Find the auto-provisioned Ecommerce Categories collection.

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

Хуков нет.

Возвращает

string|null. Collection ID or null if not found.

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

// private - только в коде основоного (родительского) класса
$result = $this->find_category_collection_id( $collections ): ?string;
$collections(array<int,object>) (обязательный)
List of collection objects.

Код WebflowFetcher::find_category_collection_id() WC 11.2.2

private function find_category_collection_id( array $collections ): ?string {
	foreach ( $collections as $collection ) {
		if ( ! is_object( $collection ) || empty( $collection->id ) ) {
			continue;
		}
		$slug         = isset( $collection->slug ) ? (string) $collection->slug : '';
		$display_name = isset( $collection->displayName ) ? (string) $collection->displayName : ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Webflow API uses camelCase.

		if ( 'category' === $slug || 'Categories' === $display_name ) {
			return (string) $collection->id;
		}
	}

	return null;
}