Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
QueryBuilder::get_product_attributes_query()
Return the tax_query for the requested attributes
Метод класса: QueryBuilder{}
Хуков нет.
Возвращает
Массив
.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_product_attributes_query( $attributes );
- $attributes(массив)
- Attributes and their terms.
По умолчанию: array()
Код QueryBuilder::get_product_attributes_query() QueryBuilder::get product attributes query WC 9.8.5
private function get_product_attributes_query( $attributes = array() ) { if ( empty( $attributes ) ) { return array(); } $grouped_attributes = array_reduce( $attributes, function ( $carry, $item ) { $taxonomy = sanitize_title( $item['taxonomy'] ); if ( ! key_exists( $taxonomy, $carry ) ) { $carry[ $taxonomy ] = array( 'field' => 'term_id', 'operator' => 'IN', 'taxonomy' => $taxonomy, 'terms' => array( $item['termId'] ), ); } else { $carry[ $taxonomy ]['terms'][] = $item['termId']; } return $carry; }, array() ); return array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query 'tax_query' => array_values( $grouped_attributes ), ); }