• Resolved pretobrazza

    (@pretobrazza)


    Hello,

    As I’m dropshipping, my Gtin13 (EAN) sits in another custom field and the brands & color are sitting in their own custom attributes. Can I ever dream that there will be a way to map those within the plugin so they can be put through correctly to the Merchant center?

    Just for the story concerning the schema.org pullthrough with Yoast:
    In my paid version of Yoast SEO, I was able to set the Brand & Color to their custom attributes but for as far as the GTIN (EAN) is concerned, I was obliged to put a snippet in the php file of my template to force the schema.org code to include the GTIN code.

    I’m curious to discover the solution you propose ..

    Kind regards!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi @pretobrazza

    Google Listings & Ads provides filters for all data added to the feed. This includes the GTIN. Although it also has an integration to Yoast SEO, if this is not available to you, there is always a filter.

    The relevant filter is woocommerce_gla_product_attribute_value_GTIN.

    Adding the filter would require you to add the following snippet:

    
    add_filter("woocommerce_gla_product_attribute_value_GTIN", "my_custom_function", 10, 2 );
    
    function my_custom_function( $gtin, $product ){
    
    //make the magic happen here - something like?
    $my_new_gtin = get_post_meta( $product->get_id(), 'my_custom_gtin', true );
    
    //please make sure your new gtin is valid before switching the values
    $gtin = $my_new_gtin;
    
    return $gtin
    }
    
    Thread Starter pretobrazza

    (@pretobrazza)

    Hello @nicw,

    For anyone reading this thread, searching for a solution, there’s a small typo in the snippet above:
    return $gtin
    }
    Should be
    return $gtin;
    }
    (just a small typo error ?? )
    ____________________________

    Thank you for the snippet! I put it right under the one I use to complete the schema.org from yoast seo in the functions.php of my child template. I know for shure that the one for yoast works.

    The whole picture now looks like:

    add_filter( 'wpseo_schema_product', 'custom_set_extra_schema' );
    function custom_set_extra_schema( $data ) {
        global $product;
        
        $gtin        = get_post_meta( $product->get_id(), '_maxyzla_ean_number', true );
        $data['gtin13'] = $gtin;
        return $data;
    }
    
    add_filter( 'woocommerce_gla_product_attribute_value_GTIN' , 'my_custom_function', 10, 2 );
    function my_custom_function( $gtin, $product ){
    
    //make the magic happen here - something like?
    $my_new_gtin = get_post_meta( $product->get_id(), '_maxyzla_ean_number', true );
    
    //please make sure your new gtin is valid before switching the values
    $gtin = $my_new_gtin;
    
    return $gtin;
    }

    Afterwards I republished 3 products on my site and some minutes later merchant center picked up the change. In the GTIN column of merchant center the gtin stayed empty though.

    Is there something, I’m missing out?

    Kind regards ??

    • This reply was modified 2 years, 6 months ago by pretobrazza.
    • This reply was modified 2 years, 6 months ago by pretobrazza.

    Hi @pretobrazza

    Apologies – not only did I make a typo, I gave you the wrong filter.

    The correct filter is woocommerce_gla_product_attribute_values, which passes the set of attributes and the product object. From there the GTIN value can be fetched as needed and included in the set of attributes.

    It can also be done by updating the hidden meta fields prefixed with an underscore _wc_gla_gtin.

    This can be done by using a CSV importer / exporter if it supports updating hidden fields.

    Thread Starter pretobrazza

    (@pretobrazza)

    Hello @nicw,

    About half an hour after you responded I changed the ‘woocommerce_gla_product_attribute_value_GTIN’ to ‘woocommerce_gla_product_attribute_values’ as you suggested. In the process I changed some products which was picked up in the merchant center.

    Now, one day later, the GTIN is still not showing up in the merchant center at all.

    I’m not entirely sure how WP processes data which leaves me with the question whether functions.php really is the right place where I should place the filter.

    To be honest, I still want to give GLA a fair chance but somehow I slowly am looking to install a pro version of a third party feed generator so that (I suppose) I potentially will have full control of an array of places I can push my fully fledged feed through.

    On a young site it would be an additional expense over and above Yoast and it’s schema.org + XML feed and yet …

    Kind regards,
    Bernard

    • This reply was modified 2 years, 6 months ago by pretobrazza.
    • This reply was modified 2 years, 6 months ago by pretobrazza.

    Hi @pretobrazza

    Apologies, I should have been clearer. The code for this filter is a little different, and returns an array of attributes. It would look something like this.

    
    add_filter( 'woocommerce_gla_product_attribute_values', 'my_custom_function', 10, 3 );
    
    function my_custom_function( $attributes, $product, $adapter ) {
    
            $my_new_gtin = get_post_meta( $product->get_id(), '_maxyzla_ean_number', true );
    	$attributes['GTIN'] = $my_new_gtin;
    	return $attributes;
    }
    
    Plugin Support Chris Moreira – a11n

    (@chrism245)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

    Thread Starter pretobrazza

    (@pretobrazza)

    Hi @chrism245

    I tried the script above and let it hang in functions.php of my child template for a few days but to no avail.

    So, I installed a free version of third party feed generator plugin and used it to produce a feed with a prepended gla_ product ID + (for starters) custom fields: GTIN(EAN), Brand and Gender. Then I added the xml as a supplemental feed in Google Merchant with the instruction to fetch it once a day.

    There a miracle happenned as the Gtin, Brand and Gender appeared almost instantly into your GLA Merchant feed. (with onlt 2 local gtin errors out of 1600+ products)

    I know this opens the door to completly switch over to the other feed generator I installed, but at this point in time I’m happy to ride 2 horses at once – fot the time being instead of messing around with code which doesn’t work.

    I’m curious to read your thoughts about this approach.

    Kind regards,
    Bernard

    I’m struggling with a similar issue (RankMath generated GTIN for schema).

    @pretobrazza Please can you tell me the name of the third party plugin you used?
    Thanks in advance.

    Hi there @pretobrazza ??

    There a miracle happenned as the Gtin, Brand and Gender appeared almost instantly into your GLA Merchant feed. (with onlt 2 local gtin errors out of 1600+ products)

    I know this opens the door to completly switch over to the other feed generator I installed, but at this point in time I’m happy to ride 2 horses at once – fot the time being instead of messing around with code which doesn’t work.

    Just to clarify, how are things going so far?

    @macmaggy Feel free to start a new thread, for letting us know the specifics of the issue, please.

    Thread Starter pretobrazza

    (@pretobrazza)

    @macmaggy I’m using CTX feed (free version)

    Plugin Support Niall a11n

    (@wpniall)

    Hi there @macmaggy!

    I see we’ve been helping you via the separate forum thread we asked you to create so we can continue the conversation there: Mapping 3rd party GTIN fields.

    Thank you!

    Plugin Support Niall a11n

    (@wpniall)

    Hi there @pretobrazza!

    Bernard, I must apologize, as it seems we missed your reply from a few months ago after we closed the thread thinking you may have solved the issue.

    It sounds like Google Listings & Ads has been working due to a workaround you discovered using the free CTX feed plugin, right? We’d be happy to take a closer look at why that was necessary and to get Google Listings & Ads working on its own if needed.

    Please let us know if you’d like further help and we can take it from there! Thank you!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Custom Gtin Field and custom Brand & Color Attribute – What now?’ is closed to new replies.