Victor Ciobanu

Pentru ca fiecare intrebare este demna de un raspuns

WooCommerce free Google Product Feed

by Victor Ciobanu | 60 Comments

This tutorial will teach you how to create a Google product feed (for Google merchant center) using the products you have on your WordPress WooComerce store platform . You will be able to add the products from your woocommerce store to Google merchant centre, and have full control over the category of products they will appear on.

This tutorial is for all the people that do not want to purchase the Google Product Feed Plugin , from the WooCommerce store (or think that 50$ is a bit to much).
Free WordPress Plugin for Google Merchant

Getting products into google merchant

I will split this article into 3 sections :

  • Store Product feed Case study
  • Implementation
  • Further support

1. Store Product feed Case study
I had to design for a German client (dealershop24.de) an online store. They specialize in LED lighting solutions, so their products have a lot of technical specifications. Being used to wordpress, I decided to try to go for a ecomerce plugin that had the latest seo bells and whistles (microdata/rich snippets) so I went for woocommerce.
After all was set and done with the store, I realized that for the German market, google.de pushes a lot of “shopping results” right into the result page.Google recomends products on certain searches It’s the same with United States, Brazil, Canada, Italy, UK, Spain and a few more countries that for the sake of keeping this short I will not mention them here :). (my home country, Romania, is not one of them).
List of countries supported by google merchant

So what does this really mean ? Well it means that soon Google will show you results and prices from various “respected” stores or retailers, each time you search for a particular brand or product. Trying to always stay on the edge of SEO and Google’s crazy ideas (Google wave comes to mind) I decided to give Google Merchant a chance.
Getting your products into google merchant
My first question was how do I get “my store” listed there. The solution was simple enough, you just have to open an account. Everything is free as long as you are not from United State. (they need to pay in order to get their products shown in the result, but I have a feeling that soon enough we will all need to)
Product feed url
After I got my account id I was presented with an option to add a “new data feed”. After selecting my target country the format (googlebase) and a random data feed filename, I was left with a lot more questions than answers, like :

What format does the Google merchant data feed needs to be ?

It can be txt or XML (rss2 or atom) but I found that XML (RSS2) was the easiest to set up with the woocommerce store platform.

What information does the product feed need to contain ?
You will find additional information here : http://support.google.com/merchants/bin/answer.py?hl=en&answer=188494&topic=2473824&ctx=topic#other but keep in mind this is for an English store only !
There are country specific variables like ‘in stock’ is ‘auf lager’ for a German store, so you might need to consult your own version of that help file.
Keep in mind that Google_product_category and product_type are super case sensitive and MUST be chosen from a predefined list compiled by Google !

It’s a long list but here it goes :
id [id] – An identifier of the item
title [title] – Title of the item
description [description] – Description of the item
Google product category [Google_product_category] – Google’s category of the item
product type [product_type] – Your category of the item
link [link] – URL directly linking to your item’s page on your website
image link [image_link] – URL of an image of the item
additional image link [additional_image_link] – Additional URLs of images of the item
condition [condition] – Condition or state of the item
availability [availability] – Availability status of the item
price [price] – Price of the item
sale price [sale_price] – Advertised sale price of the item
sale price effective date [sale_price_effective_date] – Date range during which the item is on sale
brand [brand] – Brand of the item
gtin [gtin] – Global Trade Item Number (GTIN) of the item
mpn [mpn] – Manufacturer Part Number (MPN) of the item

Most of the data can be extracted from the Woocomerce store platform. (considering that you entered the information in the store)

2. Implementation of the woocommerce product feed

It’s pretty simple and straight forward :

a. You need to create your product feed and add some rewrite rules. For that you will need to add this to your theme “functions.php” file :


//Define the product feed php page
function products_feed_rss2() {
 $rss_template = get_template_directory() . '/product-feed.php';
 load_template ( $rss_template );
}
 
//Add the product feed RSS
add_action('do_feed_products', 'products_feed_rss2', 10, 1);

//Update the Rerewrite rules
add_action('init', 'my_add_product_feed');
 
//function to add the rewrite rules
function my_rewrite_product_rules( $wp_rewrite ) {
 $new_rules = array(
 'feed/(.+)' => 'index.php?feed='.$wp_rewrite->preg_index(1)
 );
 $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
 
//add the rewrite rule
function my_add_product_feed( ) {
 global $wp_rewrite;
 add_action('generate_rewrite_rules', 'my_rewrite_product_rules');
 $wp_rewrite->flush_rules();
}

Notice the “/product-feed.php” , you can change that to whatever you want as long as the file you will be using will have that name.

b. Create or upload a file called “product-feed.php” that has the folowing code in it : product-feed.php

'; ?>
 

>
 

    
    
    
    Lichtschl?uche Lichterketten
    
    
    
    
    
     'product', 'posts_per_page' => 999 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); global $product;
    ?>
    
        
        
        
        price ?>
        neu
        
        is_in_stock() ? 'auf lager' : 'vorbestellt'; ?>
		LEDWorkx
		Heim & Garten > Beleuchtung > Leuchtmittel > LED-Leuchtmittel
        Heim & Garten > Beleuchtung > Leuchtmittel > LED-Leuchtmittel
		get_weight();?>
		get_sku(); ?>

        ]]>

        ]]>

 

    
    
    


Keep in mind that this product feed code was custom made for a German client (led shop) so you will need to change some things around like :

Lichtschl?uche Lichterketten 
 neu 
 is_in_stock() ? 'auf lager' : 'vorbestellt'; ?> 
LEDWorkx 
Heim & Garten > Beleuchtung > Leuchtmittel > LED-Leuchtmittel
 Heim & Garten > Beleuchtung > Leuchtmittel > LED-Leuchtmittel

description – it can be anything
condition – you must use the proper variables for your specific country (example for English: new, used
availability – you must use the proper variables for your own country (for English:in stock, out of stock)
brand – the brand of the product
product_type – Important ! use only the Google specified product categories that you can find here http://support.google.com/merchants/bin/answer.py?hl=en&answer=160081
Google_product_category- Important ! same as above

c. Access your product feed by adding going to http://yourStore/feed/products/
d. Specify the link to your product feed in your Google merchant account and on your webmaster tools under submit sitemap.
Products are in the google merchant center with no errors
e. You are all done. It may take up to 4 days for your products to appear (given there are no errors in the submission) in the Google products results.

3. Further support
To lazy to implement the woocommerce product feed by yourself

I will offer free advice and reply to your questions related to this article.
If you are unable to implement this free tutorial on how to get your woocommerce products listed in Google products, or you find this time consuming, I will do it for your, for a nominal fee of 25$ (just think of all the things you could do with that money, get a domain name for two years, feed a family of 5 ants for a whole year, get a half-decent host for 1 month, so don’t be lazy, don’t give me the money, I’ll probably use them to buy 5 packs of cigarettes that will last me exactly 3 days… ) :P




PayPal logo

For the time being I will only work on English/German product feeds. After you acquire my services I will contact you via email within 24 hours and either work remotely using a program of your choice or just set the files up for uploading and guide you step by step on how to submit the product feed.
I will issue a full refund :
– If my schedule is too full and I am unable to contact you within 48 hours.
– If for some strage reason I am unable to get the feed working
– If you are unpleased with the results
– If I don’t like you
– If you don’t like me :)
I have started working on a wordpress plugin that I will offer free of charge (donation ware) but I do not have an estimate on when it will be completed.
(I’m a SEO guy, and I chose SEO because I’m lazy so…)

PLEASE ALWAYS SKIP TO THE LATEST UPDATE

UPDATE 03.01.2013 thanks to Taye from Iphone 5 Adapter
Server issues while accesing the rss product feed for google merchant
NOTE ! Some servers (hosts) might not return the proper answer when requesting a feed
example http://web-sniffer.net/?url=http://www.appleiphone5adapter.co.uk/feed/&uak=9&type=HEAD returns a 404. you need to ask your web-hosting company if it’s possible to return a proper header during such a request.

You can test if your server is affected by this issue by going to http://web-sniffer.net filling in your domain name and adding /feed at the end. if you get a Status: HTTP/1.1 404 Not Found , you will not be able to submit your feed to google merchant. It does not matter if you can access it in your browser (it will show up on chrome), you will not be able to submit the feed.

A simple solution would be to go to your domain.name/feed/products by using google chrome as a browser, right-click, view source, and save the content of the source to a file, rename that file to products.xml and upload it to your domain root.

You can then use the yourdomain.name/products.xml file to insert your products into google merchant or just chose Manual upload and select the file you just created.

Keep in mind that this is not a real solution, since when you either change the prices, or add a new product, you will need to repeat the procedure. The real solution is checking with the server administrator of hosting for support. (just tell them that you need the server to issue a proper response whenever someone requests a rss feed)

UPDATE 31.01.2013 Thanks to Jane There might be some issues with maya woocmerce theme. Before giving up try testing with another theme. Use this as a reference. DO NOT DEPLOY the theme commercially as it is a premium theme. (the guy who designed it might come after you (in your sleep :P ) if he finds out.

UPDATE 11.02.2013 Thanks to John; If you experience issues with the maya theme (or other themes) related to the fact that the product feed is not accessible it can be one of two possible issues :
1. You can’t access the yourdomain.tld/feed/products/ in any browser (you get a 404)
FIX : you need to turn on permalinks in your wordpress install (under settings -> permalinks -> post name)

2. You can access the yourdomain.tld/feed/products/ in chrome but you can’t submit it to google merchant or access it in any other browser (you get a 404 response)
FIX : you need to post a “post” in wordpress, so that the rss feed system gets activated/generated. do that and your theme will issue the proper response (200) when your product feed is called upon by google merchant.

Update 14.02.2013 Finally had the time to write a plugin, you can download it free here Free Woocommerce Product Feed Plugin

Posted in diy

60 Comments

  1. Hi,

    WOuld you be able to help implement this on this site? appleiphone5adapter.co.uk ?

    Thanks

  2. 100% yes. It looks like you are using mearishop theme. the only issue we would have would be related to shipping. if you offer free shipping on all products then it’s super easy to set up. if you offer a weight based shipping then you would need to add the weight for those particular products in the backend for each product. if it’s size based shipping then it’s a little bit harder (not impossible thou) to implement.
    I’ve set up a ‘somewhat’ customized file for your site here http://victorciobanu.com/appleadaptor.txt
    If you still need my help (or would like me to implement it for you, let me know)
    Cheers mate.

    • Hi Victor,

      Thanks for your prompt response. I still want you to help implement it. How do I proceed? I will go ahead and make payment now via PayPal.

      Thanks

  3. By the way, I am offering free shipping for UK customers but will charge european and rest of the world customers.

    • hey, thanks :D you are my first customer :) looks like 2013 will be a nice year :) I’ve sent you an email with my skype id. we can either do this by skype or any means of live chat, ( voice or not).

  4. I have been looking for something like this for so long! It’s worth the $25 for you to do it so I don’t mess my site up.

    I’m about to click “Buy Now!” Thanks again –s

  5. Hey, thanks for the tutorial. I tried to set this up on WrapYourselfSlim.com.au/feed/products however I get an error as you can see. Can you offer any help?

  6. hey Simon, make sure that you remove the !– from the product-feed.php file. I had to put those so the syntax would show correctly on the site.

  7. You’re amazing Victor! I checked this morning and all my products are approved and active!

    Thanks so much for your help, you’re so fast and know this stuff inside and out. It was hands down the best money I’ve ever spent.

  8. Hi Victor, Great piece of code and exactly what I was looking for thank you. Only one question, do you have cleaner up version of the code? I’ve spent the last hour trying to clear up the syntax but i’m only up to line 34.

  9. Hi,

    This really is wonderful! but on the moment not working for me. There seems to be a syntax error on line 13. I think it”s the <?php="" part. Can you maybe check what is wrong?

    Thnx,

    Wouter

  10. I’m getting a 301 redirect when I navigate to the feed/products directory. Thoughts? tech-capital.com/feed/products/

  11. Hi Victor, thanks a lot for this code! We have some products in our shop that are entered without a price, just for listing purposes. We get error messages for those because the price is missing – is there a way to exclude them?

    • Hi Peter, In theory, google merchant will exclude those by default, so you should not worry about that issue. Since my solution uses the integrated wordpress rss feed system, I can’t think of any “out-of-the-box” quick solutions (other than enforcing a set of theme function rules for those particular posts(products))

  12. Hi

    Thank you very much!

    I have followed the instructions and have added the code. As per you update, I have experienced 404 header status for adumbro.co.uk/feed/products and have contacted the hosting company who have told me that is a wordpress issue and not a server issue. After googling around I have found that many similar questions on WP forums, but no solutions. Could you please guide me in a right direction? I am not sure how to resolve this…

    • Privet,
      Just checked your feed, I used google chome browser, and the feed showed up as it should. Then I tried it in firefox, and nothing happens (no page is displayed). At this time I only have two and a half “solutions” :

      0. You try using another woocommercetheme (other than maya) just to check if that is the problem. Here is the download link to a test theme. Please do not deploy this theme commercially (on the final version of the site) as it is a paid template.

      1. (using google chome browser) You either copy the source of the created feed by right clicking http://www.adumbro.co.uk/feed/products and selecting view source, to a new file called whaterver.xml and submit that file to google merchant

      2. You try setting up your site on a different server (i can provide you with a free temporary account on one of my servers if you don’t have a backup host)
      I have hosting servers in Germany, US, Romania and Nederlands with configurations ranging from linux/windows apache/nginx/lightspeed mysql/mariadb/postgreSQL and after i’ve done the proper server setup , i managed to get the proper response on all of them. In this way you will know for a fact if it’s time to change the host (they are to lazy to do the changes needed for your site) or it’s a template/wordpress issue.

  13. Hello,
    could you help me to implement this code to my website please?
    I have added the first codes at the top of my theme “functions.php” file and then created “product-feed.php” in my theme’s folder (same folder as functions.php), inputted the second code and made the necessary changes.
    However I get a blank page when i try to navigate to the feed. My website is inner-goddess.co.uk.
    Thanks

    • Love the site and the merch btw :P
      I’ve added you on facebook. Send me a message today 31.01.2013, and we could try to see what’s wrong.
      Cheers

  14. hello
    can you help to resolve this situation proteine-integratori.it/feed/products/
    in my demo site work fine demodigiteria01.altervista.org/sitoprova/feed/products/

  15. Hey there,

    First off, thanks for making this tutorial!

    I’m using mayashop and am getting a parse error on line 11 of product-feed.php. Is this the normal error with mayashop/do you know of anything I can do to fix it?

    I haven’t tried it with another theme yet because I’m new to WordPress and am somewhat worried about breaking the site.

    Thanks again!

    • Nevermind, I missed some of the html comments.

      Thanks for this though. You saved me $50 and taught me something!

      • Sorry, I was away this weekend, so i never got to help you/read your message. I’m happy that you managed to fix it by yourself :) (you might be new to wordpress but you are definitely not new to coding :P) Glad i could provide you with the building blocks to make your product feed run.
        Cheers

        • I may have a fix to one of the mayashop issues with the google product feed.

          I ended up getting 404 response codes from the server even though I could see the XML document at

          http://www.prestigeofficeaccessories.com/feed/products

          The solution was to publish a post in wordpress. I had everything set up as pages and 0 actual posts. I guess because of the lack of posts, the wordpress rss functionality was a little screwy?

          • Oau ! John, there’s no other way to put this, except, YOU ROCK !
            I’ve spent the better part of a day, trying to debug maya theme, in order to figure out why i was getting a 404 when trying to access the feed. I never figured it out, so i either advised people to change the theme (this issue is maya particular) or to “dump” the content of the xml (you can access it in chrome) and use that file (the “dump”) for the merchant account product feed. It never ever crossed my mind, the fact that if you never “post” a post under maya the rss never gets “active” (thus sending a proper 200 response when called).
            I will post an update, asap
            Cheers, and thank you for the great feedback , this is why i wrote the post to begin with (so that people would start helping each other)

  16. With Atahualpa Theme this plugin doesn’t work.

    I have this error:

    Warning: require_once(/home/mhd-01/…/htdocs/wp-content/themes/atahualpa/product-feed.php) [function.require-once]: failed to open stream: No such file or directory in /home/mhd-01/…/htdocs/wp-includes/template.php on line 405

    Fatal error: require_once() [function.require]: Failed opening required ‘/home/mhd-01/…/htdocs/wp-content/themes/atahualpa/product-feed.php’ (include_path=’./:/usr/share/php/’) in /home/mhd-01/…/htdocs/wp-includes/template.php on line 405

    I have saved product-feed.php in the same folder of functions.php (theme folder).

    How can I fix this error?

    Thanks

    • Hi Alex,
      I currently working on a plugin, I should be ready by the end of the day with it :)
      You did something wrong… i can’t set you in the right direction at this time, but I’ll get back to you once the plugin is ready .

    • You need to upload the product-feed.php file to the theme folder NOT the public_html folder

  17. Hi Victor

    Great plugin, thanks! I seem to have it all working fine – apart from one thing – the shipping. I offer free shipping worldwide on every product so should be easy. But the feed doesn’t pick this 0.00 up anywhere so I am getting this error message:

    “Shipping is missing. Please specify in the ‘shipping’ attribute or in your account settings with a default shipping method selected for each targeted country. Note: Allow 15 minutes for account settings to take effect before uploading a new feed. Learn more.

    My products still seem to be submitted but it says all of them have an error as no shipping is defined. Any ideas? Thanks in advance for the help.

    Glenn

    • here’s what I would do, I would set up shipping in the merchant account to free shipping, or, i would set weight to my products (the weight is sent to google merchant) and then establish a set of rules in shipping. Here is an example – in merchant account under setting – tax and shipping – Merchant account shipping settings

  18. hi i have installed and activated your product feed.

    when i visit this link:

    able-goods.com/feed/products/

    i get this error report:

    Index of /feed/products

    Parent Directory
    Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 mod_qos/10.10 mod_perl/2.0.6 Perl/v5.8.8 Server at able-goods.com Port 80

    can you tell me what is wrong here?

    thanks

    • Hi,

      please enable permalinks on your site. It should work just fine after that.

      in wp-admin go to setting->permalinks->custom structure /%postname%/

      Let me know how it goes

  19. Hi,

    he does not take:

    http://www.komili.eu /%postname%/

    as custom structure

  20. do i need to create the folder feed and products by ftp?

  21. Hi i need another urgend help.

    your plugin do not works with product variation. here you have one product but with many variation:

    http://www.komili.eu/?product=komili-anti-schuppen-shampoo-aus-100-naturlichem-olivenol

    in word press you have to write the different article-no of each product in the variation option.

    can you solve this problem in your plugin.

    that is the reason why many products of me arent in google shopping.

  22. Hi Victor.

    can you help me please?

  23. You Just Awesome!

  24. Hi, I have clicked buy it now and purchased your services but the email on paypal keeps bouncing back. Please can you email me with the info you require to info@stokeontrentduck.co.uk
    Many thanks, Dave OSullivan

  25. Hi Victor,

    First of all thx for sharing your solution with the community :)

    I have one question though before I try to do this myself: Does this still work if your site has multiple brands & google product types/categories as it seems that in product-feed.php you are defining fixed values?

    brand – the brand of the product
    product_type – Important ! use only the Google specified product categories that you can find here http://support.google.com/merchants/bin/answer.py?hl=en&answer=160081
    Google_product_category- Important ! same as above

    Thx,

    Denise

  26. Don’t know if you still read this but need help with inserting a gtin field and having it fetch the attribute isbn data.

  27. Victor,

    Awesome! Thanks. Say, is the feed exclusive to the Google Merchant Centre? We need the same functionality for a remarketing agency (LiquidAds), but WP’s RSS feed does not contain images or product IDs, as you know.

    Seems like we could adopt this for that purpose, do you agree?

    Steve

  28. Hey,

    Ive been trying to solve an issue with a conflict between thew plugin and WooCommerce 2.1

    Seemings they are using script generated pages for order received ect, for some reason the plugin makes these pages 404 error. Is there an update that fixes this?

    Thanks for the great free plugin!

  29. Hi Victor,

    my feed reader can not read the feed on my website. Can you help me please. See here:

    http://feedvalidator.org/check.cgi?url=http://www.able-goods.com/feed/products/

    where is the mistake? What is wrong? how can i fix it.

    i would be glad if you can help me.

    thanks

Leave a Reply

Required fields are marked *.