How to inherit ratings on WooCommerce variable products?

I’ve created several variable products in WooCommerce, grouping similar simple products that had ratings from the Customer Reviews for WooCommerce plugin.

I have a feature that works perfectly, and the reviews are inherited. But I deleted the simple products from which the reviews were inherited, and they were lost.

Is there a way to do this through the database? Could I inherit the reviews by requesting them from the database somehow, even if the products are no longer in the WordPress dashboard?

I’d like to add that everything related to reviews is enabled. I’ve already consulted the documentation for this plugin, but I didn’t find anything about it.

I ran several tests until I found this option that worked:

add_filter( 'woocommerce_product_get_rating_counts', 'fusionar_valoraciones_heredadas', 10, 2 );
add_filter( 'woocommerce_product_get_review_count', 'fusionar_valoraciones_heredadas', 10, 2 );
add_filter( 'woocommerce_product_get_average_rating', 'fusionar_valoraciones_heredadas', 10, 2 );

function fusionar_valoraciones_heredadas( $value, $product ) {

    // Tabla de asignación: 'ID del producto nuevo' => ['IDs de los productos antiguos']
    $productos_a_fusionar = [
        24359 => [326, 327], // Nuevo producto con ID 23736 hereda de los productos 326 y 327
        24224 => [559, 972],
         24192 => [666, 667]
    ];

    // Comprobamos si el ID del producto actual está en nuestra tabla de asignación
    if ( array_key_exists( $product->get_id(), $productos_a_fusionar ) ) {

        // Si es así, obtenemos los IDs antiguos para este producto
        $ids_antiguos = $productos_a_fusionar[ $product->get_id() ];
        $rating_count = [];
        $review_count = 0;

        foreach ( $ids_antiguos as $old_id ) {
            $old_product = wc_get_product( $old_id );
            if ( $old_product ) {
                foreach ( $old_product->get_rating_counts() as $rating => $count ) {
                    if ( ! isset( $rating_count[ $rating ] ) ) {
                        $rating_count[ $rating ] = 0;
                    }
                    $rating_count[ $rating ] += $count;
                }
                $review_count += $old_product->get_review_count();
            }
        }

        if ( current_filter() == 'woocommerce_product_get_rating_counts' ) {
            return $rating_count;
        }
        if ( current_filter() == 'woocommerce_product_get_review_count' ) {
            return $review_count;
        }
        if ( current_filter() == 'woocommerce_product_get_average_rating' ) {
            $total = 0; $count = 0;
            foreach ( $rating_count as $rating => $num ) {
                $total += $rating * $num;
                $count += $num;
            }
            return $count ? round( $total / $count, 2 ) : 0;
        }
    }
    return $value;
} 

I did more tests, since the “stars of the reviews” were not visible, I thought it was due to the code… but it was because the products were simple, since my function calls them by ID.