Automattic\WooCommerce\Blocks\BlockTypes
AbstractProductGrid::get_products
Run the query and return an array of product IDs
Method of the class: AbstractProductGrid{}
Hooks from the method
Returns
Array. List of product IDs
Usage
// protected - for code of main (parent) or child class $result = $this->get_products();
AbstractProductGrid::get_products() AbstractProductGrid::get products code WC 10.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();
if ( ! empty( $results ) ) {
// Prime caches to reduce future queries.
_prime_post_caches( $results );
}
$this->prime_product_variations( $results );
return $results;
}