Automattic\WooCommerce\Internal\CLI\Migrator\Platforms\Webflow
WebflowFetcher::find_category_collection_id
Find the auto-provisioned Ecommerce Categories collection.
Method of the class: WebflowFetcher{}
No Hooks.
Returns
string|null. Collection ID or null if not found.
Usage
// private - for code of main (parent) class only $result = $this->find_category_collection_id( $collections ): ?string;
- $collections(array<int,object>) (required)
- List of collection objects.
WebflowFetcher::find_category_collection_id() WebflowFetcher::find category collection id code WC 11.1.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;
}