Automattic\WooCommerce\StoreApi\Utilities
ProductQuery::get_objects
Get objects.
Method of the class: ProductQuery{}
No Hooks.
Returns
Array.
Usage
$ProductQuery = new ProductQuery(); $ProductQuery->get_objects( $request );
- $request(WP_REST_Request) (required)
- Request data.
ProductQuery::get_objects() ProductQuery::get objects code WC 11.0.1
public function get_objects( $request ) {
$results = $this->get_results( $request );
if ( ! empty( $results['results'] ) ) {
// Prime caches to reduce future queries.
_prime_post_caches( $results['results'] );
}
$objects = array_map( 'wc_get_product', $results['results'] );
// Batch-prime image attachment caches for the whole collection, rather than once per
// product when ProductSchema::get_images() runs during serialization.
wc_get_container()->get( ProductUtil::class )->prime_image_caches( $objects );
return array(
'objects' => $objects,
'total' => $results['total'],
'pages' => $results['pages'],
);
}