Pass the GTIN and Brand data in a schema

Top WooCommerce & WordPress Plugins Forums EAN and Barcodes for WooCommerce Pass the GTIN and Brand data in a schema

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #85235
    name123
    Participant

    Hi there,

    We are already using a plugin which has the GTIN (EAN) and Brand fields which are converted into a product feed (along with other google merchant specific data) and are submitted to google merchant to be used in google ads. The plugin we use is https://www.pixelyoursite.com/plugins/product-catalog-feed-for-woocommerce (I can send you a copy of the plugin if required). The problem is the GTIN and Brand data is pushed to google merchant centre, but not to google search console, so now google merchant says our products have valid GTINs and Brand, but google search console gives us warnings that the GTIN and Brand values are missing. I have verified with google rich results test and the GTIN and Brand data are not in the structured data of the product pages. I was wondering if your plugin can help us pass the GTIN and Brand data in a schema friendly way to google search console so we can get rid of those warning in google search console (but not interfere with or duplicate the data created by the other plugin). Also, would there be an easy way to map the GTIN and Brand values from the plugin we use to your plugin? The plugin we use already provides the custom attributes for GTIN and Brand. I can see you show an example of a schema snippet where schema recognises the GTIN value provided by your plugin, but is there a way to create a Brand value for each product (we have different brands across the 1000’s of products we sell) using your plugin which will also be recognised by schema? I know I am already pushing it with this long email, but we have used your great plugins before and your great support, so I thought if it is possible to also find a way to add other product specific data to products which will be valid schema data such as any of schema product properties https://schema.org/Product (mostly – material, depth, height, width, category – as these are things we pass to google merchant with the other plugin, but we find it tricky to pass this info to google search console). Thank you in advance.

    #85378
    Tom Anbinder
    Moderator
    Plugin Support

    Hi,

    Sorry for the late reply.

    Yes, our plugin can add GTIN to the product structured data. You just need to enable the “Product structured data” checkbox in “WooCommerce > Settings > EAN > General”. Also, there shouldn’t be any issues with duplicating the data, as you can set a custom meta key in our plugin. I.e., you just need to know which meta key the feed plugin uses to store GTINs, then you set the same key in “WooCommerce > Settings > EAN > Advanced > Meta key”.

    However, brands are not covered. You can add it with a small PHP snippet, though:

    add_filter( 'woocommerce_structured_data_product', function ( $markup, $product ) {
        $markup['brand'] = 'Your brand here';
        return $markup;
    }, 10, 2 );

    Here you need to replace 'Your brand here' with an actual product brand (you can use $product->get_id(), etc. to get the product’s brand).

    I hope this helps. And please let me know if you have any questions.

    #106373
    name123
    Participant

    Hi Tom,

    Thank you for your reply. I will try the meta key for the GTINs.

    If I want to add a filter in functions.php like the brand one you pasted above and the meta key I want to use to get the brand name is wpfoof-brand what would the snippet look like?

    I would really like to be able to also create two more structured data attributes – material and colour. If I use the meta keys for material and colour from woocommerce pa_colour and pa_material what snippets can I use to create structured data attributes for color and material that will be schema friendly and follow these guidelines https://schema.org/material and https://schema.org/color ?

    Thank you in advance. I will buy the unlimited sites license if I can get these working even though I will only use it on one website.

    #120625
    Tom Anbinder
    Moderator
    Plugin Support

    Hi,

    Sorry for not getting back to you sooner.

    Please try this:

    add_filter( 'woocommerce_structured_data_product', function ( $markup, $product ) {
    
        // Attributes
        $markup['material'] = $product->get_attribute( 'material' );
        $markup['color']    = $product->get_attribute( 'colour' );
    
        // Brand
        $markup['brand'] = current( wp_list_pluck( get_the_terms( $product->get_id(), 'wpfoof-brand' ), 'name' ) );
    
        return $markup;
    }, 10, 2 );
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.