Woocommerce – How to add 5 stars to all products to test design

@Nikola‘s answer gives you what you want to need without saving anything to the database. If you need to save the values to the database and directly execute SQL, you can do the following.

Basically WooCommerce stores product reviews data as a postmeta under meta keys

  • _wc_rating_count
  • _wc_average_rating
  • _wc_review_count
UPDATE fs_postmeta SET meta_value = 5
WHERE meta_key = '_wc_average_rating' AND post_id = 564;

UPDATE fs_postmeta SET meta_value = 105 
WHERE meta_key = '_wc_review_count' AND post_id = 564;

or

<?php
/*
Plugin Name: BK
Version: 0.0.1
*/

function bk_get_all_products(  ) {

    $ps = new WP_Query( array(
        'post_type' => 'product',
        'post_status' => 'publish',
        'posts_per_page' => '-1'
    ) );
    $arr = array();
    while($ps->have_posts()){
      $ps->the_post();
      $arr[] = get_the_ID();
    }
    return $arr;
}

add_action('init','bk');
function bk(){
  $products = bk_get_all_products();
  // $re = array(
  //   "1" => 1,
  //   "2" => 2,
  //   "3" => 3,
  //   "4" => 5,
  //   "5" => 6,
  // );
  foreach ($products as $key => $value) {
    update_post_meta( $value, '_wc_average_rating', 1 );
    update_post_meta( $value, '_wc_review_count', 15 );
    // update_post_meta( $value, '_wc_rating_count', $re );
  }
}

Remember with this we are not changing the reviews list that appears under product tabs.