Automattic\WooCommerce\Blocks\BlockTypes
ProductCollection::build_frontend_query()
Return a custom query based on attributes, filters and global WP_Query.
Метод класса: ProductCollection{}
Хуков нет.
Возвращает
Массив
.
Использование
$ProductCollection = new ProductCollection(); $ProductCollection->build_frontend_query( $query, $block, $page );
- $query(WP_Query) (обязательный)
- The WordPress Query.
- $block(WP_Block) (обязательный)
- The block being rendered.
- $page(int) (обязательный)
- The page number.
Код ProductCollection::build_frontend_query() ProductCollection::build frontend query WC 9.4.2
public function build_frontend_query( $query, $block, $page ) { // If not in context of product collection block, return the query as is. $is_product_collection_block = $block->context['query']['isProductCollectionBlock'] ?? false; if ( ! $is_product_collection_block ) { return $query; } $block_context_query = $block->context['query']; // phpcs:ignore WordPress.DB.SlowDBQuery $block_context_query['tax_query'] = ! empty( $query['tax_query'] ) ? $query['tax_query'] : array(); $inherit = $block->context['query']['inherit'] ?? false; $filterable = $block->context['query']['filterable'] ?? false; $is_exclude_applied_filters = ! ( $inherit || $filterable ); return $this->get_final_frontend_query( $block_context_query, $page, $is_exclude_applied_filters ); }