Google Search Console won't recognize 'brand' on WooCommerce

Viewed 1428

Google Search Console is telling me that I'm missing 'brand' on my website while it's there.

Here is the error in Google Search Console

4 warnings
Missing field 'aggregateRating' (optional)
Missing field 'review' (optional)
Missing field 'brand' (optional)
No global identifier provided (e.g. gtin, mpn, isbn) (optional)

Here is the actual code on my website:

<div class="brand">
<a href="https://www.example.com/brands/alcon/">
<img src="https://www.example.com/wp-content/uploads/2020/03/alcon-min.png" alt="Alcon" data-lazy-src="https://www.example.com/wp-content/uploads/2020/03/alcon-min.png" class="lazyloaded" data-was-processed="true"><noscript>
<img src="https://www.example.com/wp-content/uploads/2020/03/alcon-min.png" alt="Alcon" /></noscript></a>
</div>

Can anyone tell me what I'm doing wrong?

1 Answers

Hope is not to late for the answer. Place this code in your theme functions (better made a functions in mu-plugins):

// Missing field brand and No global identifier provided
function adidoro_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'] = array(
  '@type' => 'Brand',
  'name' => 'YOURBRANDNAME',
);
return $markup;
};
add_filter( 'woocommerce_structured_data_product', 'adidoro_filter_woocommerce_structured_data_product', 10, 2 );

Change YOURBRANDNAME, and be sure that is on your product page, not only in code. For ratings you need to have ratings on your products.

Related