Hello,
Thank you for contacting Rank Math, and sorry for any inconvenience caused.
Rank Math takes the schema data from your product pages automatically and turns it into Schema-ready content. Likewise, the aggregateRating and review fields are taken from your actual product reviews that your buyers/customers leave on your products.

If you don’t have any reviews yet, that is going to show up as a warning in the schema testing tool. That’s because Google will actually look for those fields.
Please acquire some reviews and ratings to get rid of the aggregateRating and review warnings.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Thank you for the answer 🙂
But this ONLY happen to out of stock products?!
Option 1
Can I add a snippet to funcitons.php that removes schema/rich data if products are out of stock? Or set the products to noindex
Option 2
I do not plan to have reviews and ratings on my site.
The function is disabled.
Can I set aggregateRating and review to ALWAYS have a DEFAULT value? so the error dosent show? – Note that it is not a warning but an error in search console
Hello,
Please copy the filter given below and paste it inside your theme/child theme’s functions.php file:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
global $product;
If (is_product()) {
if($product->get_stock_status() == 'outofstock') {
return[];
}
}
return $data;
}, 99, 2);
This will remove the Schema data from the out-of-stock products.
Hope this helps. Let us know if you need any further assistance.
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.