Automattic\WooCommerce\Internal\ProductFeed\Mapping
UcpProductMapper::build_categories
Build product categories from Store API terms.
Method of the class: UcpProductMapper{}
No Hooks.
Returns
array.
Usage
// private - for code of main (parent) class only $result = $this->build_categories( $terms ): array;
- $terms(array) (required)
- Store API category objects.
UcpProductMapper::build_categories() UcpProductMapper::build categories code WC 11.3.0
private function build_categories( array $terms ): array {
$categories = array();
foreach ( array_slice( $terms, 0, self::MAX_TERMS_PER_PRODUCT ) as $term ) {
$categories[] = array(
'id' => (string) $term['id'],
'name' => (string) $term['name'],
'value' => (string) $term['slug'],
);
}
return $categories;
}