Use core so that any future improvements need to be done in one place.
Right now controller creates and executes its own query, whereas core already has a way to execute this. So it makes sense to use so that we would have to do any future improvement in one place.
This commit is contained in:
parent
d560e73fce
commit
24baf27570
|
@ -217,6 +217,25 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get products.
|
||||||
|
*
|
||||||
|
* @param array $query_args Query args.
|
||||||
|
*
|
||||||
|
* @return array Products.
|
||||||
|
*/
|
||||||
|
protected function get_objects( $query_args ) {
|
||||||
|
$query_args['paginate'] = true;
|
||||||
|
$query_args['return'] = 'objects';
|
||||||
|
$results = wc_get_products( $query_args );
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'objects' => $results->products,
|
||||||
|
'total' => $results->total,
|
||||||
|
'pages' => $results->max_num_pages,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set product images.
|
* Set product images.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue