Automattic\WooCommerce\Blocks\BlockTypes

ProductQuery::get_products_ids_by_attributes()privateWC 1.0

Return the product ids based on the attributes and global query. This is used to allow the filter blocks to render data that matches with variations. More details here: https://github.com/woocommerce/woocommerce-blocks/issues/7245

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

Хуков нет.

Возвращает

Массив.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_products_ids_by_attributes( $parsed_block );
$parsed_block(массив) (обязательный)
The block being rendered.

Код ProductQuery::get_products_ids_by_attributes() WC 7.3.0

private function get_products_ids_by_attributes( $parsed_block ) {
	$query = $this->merge_queries(
		array(
			'post_type'      => 'product',
			'post__in'       => array(),
			'post_status'    => 'publish',
			'posts_per_page' => -1,
			'meta_query'     => array(),
			'tax_query'      => array(),
		),
		$this->get_queries_by_attributes( $parsed_block ),
		$this->get_global_query( $parsed_block )
	);

	$products = new \WP_Query( $query );
	$post_ids = wp_list_pluck( $products->posts, 'ID' );

	return $post_ids;
}