Today I came across and issue where Google Search Console was complaning products “brand” and “mpn” where missing from the products schema / rich snippets data. You can checking using the rich snippet testing tool by Google found here.
https://search.google.com/structured-data/testing-tool
I fixed my issue by adding a WordPress filter using the “woocommerce_structured_data_product” filter option. This allows you to add new data to the already generated WooCommerce data.
This is an example. You will need to change for your implementation.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/* * Rich Snippet Data * Add missing data not handled by WooCommerce yet */ function custom_woocommerce_structured_data_product ($data) { global $product; $data[‘brand’] = $data[‘brand’] = [‘@type’ => ‘Brand’, ‘name’ => $product–>get_attribute(‘pa_manufacturer’) ?? null]; $data[‘mpn’] = $product–>get_sku() ?? null; return $data; } add_filter( ‘woocommerce_structured_data_product’, ‘custom_woocommerce_structured_data_product’ ); |

Leave a Reply