Automattic\WooCommerce\Blocks\BlockTypes

AbstractProductGrid::get_products()protectedWC 1.0

Run the query and return an array of product IDs

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

Возвращает

Массив. List of product IDs

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_products();

Код AbstractProductGrid::get_products() WC 8.7.0

protected function get_products() {
	/**
	 * Filters whether or not the product grid is cacheable.
	 *
	 * @param boolean $is_cacheable The list of script dependencies.
	 * @param array $query_args Query args for the products query passed to BlocksWpQuery.
	 * @return array True to enable cache, false to disable cache.
	 *
	 * @since 2.5.0
	 */
	$is_cacheable      = (bool) apply_filters( 'woocommerce_blocks_product_grid_is_cacheable', true, $this->query_args );
	$transient_version = \WC_Cache_Helper::get_transient_version( 'product_query' );

	$query   = new BlocksWpQuery( $this->query_args );
	$results = wp_parse_id_list( $is_cacheable ? $query->get_cached_posts( $transient_version ) : $query->get_posts() );

	// Remove ordering query arguments which may have been added by get_catalog_ordering_args.
	WC()->query->remove_ordering_args();

	// Prime caches to reduce future queries. Note _prime_post_caches is private--we could replace this with our own
	// query if it becomes unavailable.
	if ( is_callable( '_prime_post_caches' ) ) {
		_prime_post_caches( $results );
	}

	$this->prime_product_variations( $results );

	return $results;
}