Solve Woocommerce – search console issue: Missing field brand, aggregateRating, review, and No global identifier provided

If you are using woocommerce + wordpress and you have errors in Google Search Console with the following Microdata properties:

Missing field “aggregateRating”
Warning Missing field “review”
Warning Missing field “brand”
Warning No global identifier provided (e.g., gtin, mpn, isbn)

then to solve the problem, you can use the code below inserted in functions.php, from the theme used:

function byrev_filter_woocommerce_structured_data_product( $markup, $product ) {
  if (empty($markup['mpn']))
        $markup['mpn'] = $markup['sku'];

  if (empty($markup['brand']))
        $markup['brand'] = $product->get_attribute( 'pa_brand' );
  if (empty($markup['brand']))
    $markup['brand'] = 'unknown';		

    if (empty($markup['aggregateRating']))
    $markup['aggregateRating'] = array(
      '@type' => 'AggregateRating',
      'ratingValue' => 5,
      'reviewCount' => 1,

    if (empty($markup['review']))
    $markup['review'] = array(
      '@type'=> 'Review',
      'reviewRating'=> [
        '@type'=> 'Rating',
        'ratingValue'=> '5',
        'bestRating'=> '5'
      'author'=> [
        '@type'=> 'Person',
        'name'=> ''

    return $markup;

add_filter( 'woocommerce_structured_data_product', 'byrev_filter_woocommerce_structured_data_product', 10, 2 );

Happy Coding!

byrev Written by:


  1. Philip Polaski
    May 3, 2020

    Thanks for the code, I was able to resolve our Rich Results Products warnings from Google Search Console.
    Note – there’s a few ;. instances in the code example, were we had to remove the (.) from the PHP code.
    Thank you very much!

    • byrev
      June 29, 2020

      I’m glad it was useful, I made the corrections for “dots”, wordpress probably got more stupid and changed something in the “code” text!

  2. May 31, 2020

    It worked on my website, It used woocommerce on my pet website.

    I am getting same 4 errors, you shown in tutorial.

    Thanks once again. Cheers!!!!

    • byrev
      June 29, 2020

      I’m glad you found it useful … Have a good life !

  3. mahdi rahimi
    September 7, 2020

    Oh God. it’s working :)))
    thanke you for code… be happy

    • asfandyar khan
      September 29, 2020

      Did you made any changes to the code??

    • byrev
      January 14, 2021

      Hi, no change until now !

  4. Anouar
    January 28, 2021

    I’m grateful for you, this code solved the problem.
    thank you so much

Leave a Reply

Your email address will not be published. Required fields are marked *