wc_get_products() not return the images details

Question

When I try to fetch products using the official REST API, returned product contains the a property named images which is an array and contains the URL to image of product.
But when I fetch using this method, it fetches other details but not the image.

    $productsQuery= wc_get_products(array(
        'limit' => 10,
        'status' => 'publish',
    ));
    $products = array();
    foreach ($productsQuery as $product) {
        $products[] = $product->get_data();
    }
    return new WP_REST_Response($products, 200);

how can I make this to return the images property as well.

0
, , Lint 1 year 2020-07-25T04:10:46-05:00 0 Answers 56 views 0

Leave an answer

Browse
Browse