Home > Magento > Products in Google Shopping Results

Products in Google Shopping Results

Posted on: 26th Mar 2010 By: Robert Kent 114 Comments

There is an updated version of this post available here

Have you ever wondered why your Magento Shop content gets indexed by Google but does not appear in Google’s own shopping results (Google Product Search)? The fact of the matter is that you need to do a few things first before you can get your products to appear in the shopping list and in the shopping results.

Magento does have an in-built feature called Google Base. What is SUPPOSED to happen is that when you perform the necessary tasks using the magento base menu Google will pick up your products and away you go…

However here at E-Commerce Web Design have always had problems with Magento’s inbuilt Google Base option. So here is the alternative…

To sidetrack any problems that you might have with the magento features simply do the following:

- Create a folder called export on your root layer.

- Create a blank text file in there named “google_base_feed.txt”.

- Create another file in there called “gbase.php”.

- Modify the permissions of the folder to 777 and the permissions to google_base_feed.txt to 777.

You can then open up gbase.php and paste in the following code (there’s also a link to the actual file at the bottom of the page):

<?php // Code updated 3rd May 2011
define('SAVE_FEED_LOCATION','google_base_feed.txt');//you can set a new folder and file if you want, don't forget to chmod the folder to 777

// make sure we don't time out
set_time_limit(0);

require_once '../app/Mage.php';
Mage::app('default'); // or use Mage::app(); for later versions of magento

try{
$handle = fopen(SAVE_FEED_LOCATION, 'w');

$heading = array('id','title','description','link','image_link','price','brand','product_type','condition');
$feed_line=implode("\t", $heading)."\r\n";
fwrite($handle, $feed_line);

//---------------------- GET THE PRODUCTS
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('status', 1);//enabled
$products->addAttributeToFilter('visibility', 4);//catalog, search
$products->addAttributeToSelect('*');
$prodIds=$products->getAllIds();

//echo 'Product filter: '.memory_get_usage(false).'<br>';
//flush();

$product = Mage::getModel('catalog/product');

foreach($prodIds as $productId) {

$product->load($productId);

$product_data = array();
$product_data['sku']=$product->getSku();
$product_data['title']=$product->getName();
$product_data['description']=iconv("UTF-8","UTF-8//IGNORE",$product->getDescription()); // removes most the utf8 errors (doesnt like row if empty too!)
$product_data['Deeplink']="http://".$_SERVER['HTTP_HOST']."/".$product->getUrlPath(); // thanks to hamish for this
$product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
 if($product->getData('special_price') != NULL){ // update to check for special price or discount
 $product_data['price'] = round($product->getData('special_price'),2);
 } else {
 $product_data['price'] = round($product->getPrice(),2);
 }
$product_data['brand']=$product->getManufacturer();
$product_data['product_type']='';
$product_data['condition']="new";

//get the product categories
foreach($product->getCategoryIds() as $_categoryId){
$category = Mage::getModel('catalog/category')->load($_categoryId);
$product_data['product_type'].=$category->getName().', ';
}
$product_data['product_type']=rtrim($product_data['product_type'],', ');

//sanitize data
foreach($product_data as $k=>$val){
$bad=array('"',"\r\n","\n","\r","\t");
$good=array(""," "," "," ","");
$product_data[$k] = '"'.str_replace($bad,$good,$val).'"';
}

$feed_line = implode("\t", $product_data)."\r\n";
fwrite($handle, $feed_line);
fflush($handle);

}

//---------------------- WRITE THE FEED
fclose($handle);

}
catch(Exception $e){
die($e->getMessage());
}

OK, now looking at this code you may think it a bit of a mess but here is what it does:

- Opens a connection with Magento

- Opens the blank text file

- Iterates through your products and creates a comma-delimited map that Google will read – including image paths/prices/description/name and product code etc.

- Writes the file ready to upload to Google.

Now all that is left is to create your Google merchant account at Google/Merchants navigate to data feeds and submit your txt file like so (I prefer manual upload myself):

What you can now do is check the Analytics of any impressions and clicks on your products – much like a PPC campaign!

Here is the file that contains the following:

- Export Folder

- gbase.php

- google_base_feed.txt

Finally visit youdomain.com/export/gbase.php to process it.

For those of you having trouble with prices causing an error – go into your google merchant account click “edit” next to your feed and then find the box that says – “use Quoted fields” and set to yes or alternatively do a find/replace on all quotation marks in your text file – thanks go out to Neil Bradley for this one.

id    title    description    link    image_link    price    brand    product_type    condition
“AMTOX”    ”Aston Martin Thrill “    ”<p>The Aston Martin Thrill allows you to drive the stunning Aston Martin DB9 and feel the power of it’s fantastic V12 engine.</p>”    ”http://www.udrivecars.com/aston-martin-thrill.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/d/o/doubledb9-249×166.jpg”    ”85″    ”No”    ”Aston Martin Driving Experiences, View All Driving Experiences”    ”new”
“AMEOX”    ”Aston Martin Experience”    ”<p>Drive the stunning Aston Martin then recieve a thrilling hotlap ride!</p>”    ”http://www.udrivecars.com/aston-martin-experience.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/a/s/ast2edit-joe.jpg”    ”95″    ”No”    ”Aston Martin Driving Experiences, View All Driving Experiences”    ”new”
“CATOX”    ”Caterham Thrill”    ”<p>It’s the nearest thing to a Go-kart and oh what fun!</p>”    ”http://www.udrivecars.com/caterham-thrill.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file.jpg”    ”50″    ”No”    ”View All Driving Experiences, Caterham Driving Experiences”    ”new”
“LOTOX”    ”Lotus Thrill”    ”<p>This lively spots car will bring a smile to any driver’s face!</p>”    ”http://www.udrivecars.com/lotus-thrill.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file_1.jpg”    ”65″    ”No”    ”View All Driving Experiences, Lotus Driving Experiences”    ”new”
“EVOOX”    ”Mitsubishi Evo Thrill”    ”<p>Feel over 300 Bhp pushing you back in the seat!</p>”    ”http://www.udrivecars.com/mitsubishi-evo-thrill.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/i/m/img_2170.jpg”    ”65″    ”No”    ”View All Driving Experiences, Evo Driving Experiences”    ”new”
“SUBTOX”    ”Subaru Impreza Thrill”    ”<p>Drive the very latest in turbo charged 4WD rice rockets!</p>”    ”http://www.udrivecars.com/subaru-impreza-thrill.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/i/m/img_7866.jpg”    ”65″    ”No”    ”View All Driving Experiences, Subaru Driving Experiences”    ”new”
“R8TOX”    ”Audi R8 Thrill”    ”<p>Described by Jeremy Clarkson as one of the all time greats!</p>”    ”http://www.udrivecars.com/audi-r8-thrill.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/r/8/r8.jpg”    ”75″    ”No”    ”Audi R8 Driving Experiences, View All Driving Experiences”    ”new”
“FTOX”    ”Ferrari Thrill”    ”<p>The Ferrari 360 is the ultimate and original supercar.</p>”    ”http://www.udrivecars.com/ferrari-thrill.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/2/f2edit-joe.jpg”    ”85″    ”No”    ”Ferrari Driving Experiences, View All Driving Experiences, Special Offers”    ”new”
“LATOX”    ”Lamborghini Thrill”    ”<p>Drive the stunning Lamborghini – true Italian stallion.</p>”    ”http://www.udrivecars.com/lamborghini-thrill.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lamedit-joe.jpg”    ”85″    ”No”    ”Lamborghini Driving Experiences, View All Driving Experiences”    ”new”
“R8EOX”    ”Audi R8 Experience”    ”<p>After your driving session in this awesome Sports Car you will have a high speed ride in a different car.</p>”    ”http://www.udrivecars.com/audi-r8-experience.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/i/m/img_6415.jpg”    ”85″    ”No”    ”Audi R8 Driving Experiences, View All Driving Experiences”    ”new”
“FEOX”    ”Ferrari Experience”    ”<p>The Driving Experience extends the Ferrari Thrill to include a High Speed Ride.</p>”    ”http://www.udrivecars.com/ferrari-experience.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/3/f3edit-joe.jpg”    ”95″    ”No”    ”Ferrari Driving Experiences, View All Driving Experiences”    ”new”
“LAEOX”    ”Lamborghini Experience”    ”<p>Lamborghini manufacture top of the range sports cars and this is your chance to drive one!</p>”    ”http://www.udrivecars.com/lamborghini-experience.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lam2edit-joe.jpg”    ”95″    ”No”    ”Lamborghini Driving Experiences, View All Driving Experiences”    ”new”
“LvCOX”    ”Lotus v Caterham”    ”<p>Find out why people rave about these super light, super fast British Sports Cars.</p>”    ”http://www.udrivecars.com/lotus-v-caterham.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/o/lotcatjoe-edit.jpg”    ”110″    ”No”    ”View All Driving Experiences, Top Sellers, Lotus Driving Experiences, Caterham Driving Experiences”    ”new”
“SvEOX”    ”Subaru v Evo “    ”<p>These Mega Horsepower TURBO saloons will blow you away!</p>”    ”http://www.udrivecars.com/subaru-v-evo.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/s/u/subevojoe-edit.jpg”    ”120″    ”No”    ”View All Driving Experiences, Subaru Driving Experiences, Evo Driving Experiences”    ”new”
“FvEOX”    ”Ferrari v Evo”    ”<p>Two top cars at a fantastic price!</p>”    ”http://www.udrivecars.com/ferrari-v-evo.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/v/fveedit-joe.jpg”    ”125″    ”No”    ”Ferrari Driving Experiences, View All Driving Experiences, Evo Driving Experiences”    ”new”
“PvLOX”    ”Porsche v Lotus”    ”<p>This is your opportunity to experience two of the greatest track cars ever made.</p>”    ”http://www.udrivecars.com/porsche-v-lotus.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/p/v/pvledit-joe.jpg”    ”130″    ”No”    ”View All Driving Experiences, Porsche Driving Experiences, Lotus Driving Experiences”    ”new”
“PLCOX”    ”Porsche v Lotus v Caterham”    ”<p>Three fun sports cars at a very attractive price!</p>”    ”http://www.udrivecars.com/porsche-v-lotus-v-caterham.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/p/l/plcedit-joe.jpg”    ”160″    ”No”    ”View All Driving Experiences, Porsche Driving Experiences, Lotus Driving Experiences, Caterham Driving Experiences”    ”new”
“SELOX”    ”Subaru v Evo v Lotus”    ”<p>Three different cars with one thing in common, lots of fun.</p>”    ”http://www.udrivecars.com/subaru-v-evo-v-lotus.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/s/e/seledit-joe.jpg”    ”160″    ”No”    ”View All Driving Experiences, Top Sellers, Subaru Driving Experiences, Lotus Driving Experiences, Evo Driving Experiences”    ”new”
“RvPOX”    ”Audi R8 v Porsche “    ”<p>Similar in price at around &pound;80,000 but are they similar in how they drive?</p>”    ”http://www.udrivecars.com/audi-r8-v-porsche-911.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/r/v/rvpedit-joe.jpg”    ”175″    ”No”    ”Audi R8 Driving Experiences, View All Driving Experiences, Special Offers, Porsche Driving Experiences”    ”new”
“AvPOX”    ”Aston Martin v Porsche “    ”<p>The legendary Porsche and iconic Aston Martin…..</p>”    ”http://www.udrivecars.com/aston-martin-v-porsche-911.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/a/v/avpedit-joe.jpg”    ”185″    ”No”    ”Aston Martin Driving Experiences, View All Driving Experiences, Special Offers, Porsche Driving Experiences”    ”new”
“FvPOX”    ”Ferrari v Porsche “    ”<p>Put these dream cars through their paces!</p>”    ”http://www.udrivecars.com/ferrari-v-porsche.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/v/fvpedit-joe.jpg”    ”185″    ”No”    ”Ferrari Driving Experiences, View All Driving Experiences, Porsche Driving Experiences”    ”new”
“FvROX”    ”Ferrari v Audi R8″    ”<p>How does the new Audi R8 compare to a Ferrari?</p>”    ”http://www.udrivecars.com/ferrari-v-audi-r8.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/v/fvredit-joe.jpg”    ”185″    ”No”    ”Ferrari Driving Experiences, Audi R8 Driving Experiences, View All Driving Experiences, Special Offers”    ”new”
“LvROX”    ”Lamborghini v Audi R8″    ”<p>The Audi R8 has taken the Supercar market by storm, can it upset Lamborghini?</p>”    ”http://www.udrivecars.com/lamborghini-v-audi-r8.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lam3edit-joe.jpg”    ”185″    ”No”    ”Lamborghini Driving Experiences, Audi R8 Driving Experiences, View All Driving Experiences, Special Offers”    ”new”
“AvROX”    ”Aston Martin v Audi R8″    ”<p>England v Germany, but who will win?</p>”    ”http://www.udrivecars.com/aston-martin-v-audi-r8.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/r/v/rvastedit-joe.jpg”    ”185″    ”No”    ”Aston Martin Driving Experiences, Audi R8 Driving Experiences, View All Driving Experiences, Special Offers”    ”new”
“LvPOX”    ”Lamborghini v Porsche”    ”<p>Two fantastic world renowned sports cars!</p>”    ”http://www.udrivecars.com/lamborghini-v-porsche.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/v/lvpedit-joe.jpg”    ”185″    ”No”    ”Lamborghini Driving Experiences, View All Driving Experiences, Special Offers, Porsche Driving Experiences”    ”new”
“AvLaOX”    ”Aston Martin v Lamborghini”    ”<p>Two top of the range sports cars, both worth over &pound;100k!</p>”    ”http://www.udrivecars.com/aston-martin-v-lamborghini.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/a/v/avlaedit-joe.jpg”    ”195″    ”No”    ”Aston Martin Driving Experiences, Lamborghini Driving Experiences, View All Driving Experiences, Special Offers, Top Sellers”    ”new”
“FLAOX”    ”Ferrari v Lamborghini”    ”<p>Both are Italian, both have their engines in the back.. Both are awesome!</p>”    ”http://www.udrivecars.com/ferrari-v-lamborghini.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/v/fvlaedit-joe.jpg”    ”195″    ”No”    ”Ferrari Driving Experiences, Lamborghini Driving Experiences, View All Driving Experiences, Special Offers”    ”new”
“FvAOX”    ”Ferrari v Aston”    ”<p>Two of the world’s most renowned sports cars!</p>”    ”http://www.udrivecars.com/ferrari-v-aston.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/v/fvaedit-joe.jpg”    ”195″    ”No”    ”Ferrari Driving Experiences, Aston Martin Driving Experiences, View All Driving Experiences, Special Offers”    ”new”
“SCEOX”    ”Supercar Experience”    ”<p>A fabulous opportunity to drive four stunning high performance cars!</p>”    ”http://www.udrivecars.com/supercar-experience.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/s/c/sc4edit-joe.jpg”    ”225″    ”No”    ”Ferrari Driving Experiences, Supercar Driving Experiences, View All Driving Experiences, Top Sellers, Porsche Driving Experiences, Subaru Driving Experiences, Lotus Driving Experiences”    ”new”
“FALOX”    ”Ferrari v Aston v Lambo”    ”<p>Three fantastic cars, at a fantastic price.</p>”    ”http://www.udrivecars.com/ferrari-v-aston-v-lambo.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/a/faledit-joe.jpg”    ”255″    ”No”    ”Ferrari Driving Experiences, Aston Martin Driving Experiences, Lamborghini Driving Experiences, Supercar Driving Experiences, View All Driving Experiences”    ”new”
“SC5OX”    ”Supercar Five”    ”<p>Aston Martin, Ferrari, Porsche, Subaru or Lotus . . .</p>”    ”http://www.udrivecars.com/supercar-five.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/s/c/sc5edit-joe.jpg”    ”275″    ”No”    ”Ferrari Driving Experiences, Aston Martin Driving Experiences, Supercar Driving Experiences, View All Driving Experiences, Porsche Driving Experiences, Subaru Driving Experiences, Lotus Driving Experiences”    ”new”
“USCOX”    ”Ultimate Supercar”    ”<p>Four of the best Supercars in the world</p>”    ”http://www.udrivecars.com/ultimate-supercar.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/u/s/uscedit-joe.jpg”    ”295″    ”No”    ”Ferrari Driving Experiences, Aston Martin Driving Experiences, Lamborghini Driving Experiences, Supercar Driving Experiences, View All Driving Experiences, Top Sellers, Porsche Driving Experiences”    ”new”
“USCDOOX”    ”Ultimate Supercar Double”    ”<p>This once in a lifetime experience is every drivers fantasy selection.</p>”    ”http://www.udrivecars.com/ultimate-supercar-double.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file_2_1.jpg”    ”575″    ”No”    ”Ferrari Driving Experiences, Aston Martin Driving Experiences, Lamborghini Driving Experiences, Supercar Driving Experiences, View All Driving Experiences, Special Offers, Porsche Driving Experiences”    ”new”
“FDEXCOX”    ”First Drive Exclusive”    ”<p>One-to-one driver training for U17s!</p>”    ”http://www.udrivecars.com/first-drive-exclusive.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/t/e/teenagers-thumbs-up-happy.jpg”    ”195″    ”No”    ”Childrens Driving Experiences, Special Offers”    ”new”
“FDOX”    ”First Drive”    ”<p>A great fun way to introduce youngsters to the art of driving!</p>”    ”http://www.udrivecars.com/first-drive.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/2/0/2005_1119heyford06pics0053.jpg”    ”70″    ”No”    ”Childrens Driving Experiences”    ”new”
“RI-DM”    ”Rally Intro”    ”<p>Tarmac and gravel… Brilliant!</p>”    ”http://www.udrivecars.com/rally-intro.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/s/v/sve-dm-edit.jpg”    ”99″    ”No”    ”Rally Driving Experiences, View All Driving Experiences, Subaru Driving Experiences, Evo Driving Experiences”    ”new”
“RALSILV-DM”    ”Rally Silver”    ”<p>The Rally Silver Experience gives you the chance to learn a unique set of driving skills required for rally driving.</p>”    ”http://www.udrivecars.com/rally-silver.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/p/u/pug-dm-edit.jpg”    ”165″    ”No”    ”Rally Driving Experiences, View All Driving Experiences, Subaru Driving Experiences, Evo Driving Experiences”    ”new”
“RALGOLD-DM”    ”Rally Gold”    ”<p>Double the Rally Silver!</p>”    ”http://www.udrivecars.com/rally-gold.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file_3_1.jpg”    ”249″    ”No”    ”Rally Driving Experiences, View All Driving Experiences, Subaru Driving Experiences, Evo Driving Experiences”    ”new”
“AMT-NAT”    ”Aston Martin Thrill “    ”<p>If all you want to do is drive an Aston Martin then this is the experience for you.</p>”    ”http://www.udrivecars.com/aston-martin-thrill-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/a/s/astedit-joe.jpg”    ”89″    ”No”    ”Aston Martin Driving Experiences, View All Driving Experiences”    ”new”
“AME-NAT”    ”Aston Martin Experience”    ”<p>Nationwide Aston Martin drive!</p>”    ”http://www.udrivecars.com/aston-martin-experience-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/a/s/ast3edit-joe.jpg”    ”99″    ”No”    ”Aston Martin Driving Experiences, View All Driving Experiences”    ”new”
“R8T-NAT”    ”Audi R8 Thrill”    ”<p>Make your own judgement on this stunning Supercar. See if you agree with Top Gear’s rave reviews.</p>”    ”http://www.udrivecars.com/audi-r8-thrill-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/r/8/r8joe-edit.jpg”    ”89″    ”No”    ”Audi R8 Driving Experiences, View All Driving Experiences”    ”new”
“R8E-NAT”    ”Audi R8 Experience”    ”<p>Described by Top Gears Jeremy Clarkson as an all time great.</p>”    ”http://www.udrivecars.com/audi-r8-experience-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/r/8/r83joe-edit.jpg”    ”99″    ”No”    ”Audi R8 Driving Experiences, View All Driving Experiences”    ”new”
“GV50″    ”£50 Voucher”    ”<p>Flexible Gift Voucher.</p>”    ”http://www.udrivecars.com/50-voucher.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/a/faledit-joe_1.jpg”    ”50″    ”No”    ”Gift Vouchers”    ”new”
“GV100″    ”£100 Voucher”    ”<p>Flexible Gift Voucher.</p>”    ”http://www.udrivecars.com/100-voucher.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lam3edit-joe_1.jpg”    ”100″    ”No”    ”Gift Vouchers”    ”new”
“GV150″    ”£150 Voucher”    ”<p>Flexible Gift Voucher.</p>”    ”http://www.udrivecars.com/150-voucher.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file_3_2.jpg”    ”150″    ”No”    ”Gift Vouchers”    ”new”
“GV200″    ”£200 Voucher”    ”<p>Flexible Gift Voucher.</p>”    ”http://www.udrivecars.com/200-voucher.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lam-edit-joe_1.jpg”    ”200″    ”No”    ”Gift Vouchers”    ”new”
“GV250″    ”£250 Voucher”    ”<p>Flexible Gift Voucher.</p>”    ”http://www.udrivecars.com/250-voucher.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file_3_3.jpg”    ”250″    ”No”    ”Gift Vouchers”    ”new”
“PTOX”    ”Porsche Thrill”    ”<p>Drive the staggering Porsche 911.</p>”    ”http://www.udrivecars.com/porsche-thrill.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file_3.jpg”    ”70″    ”No”    ”View All Driving Experiences, Porsche Driving Experiences”    ”new”
“JF-DM”    ”Junior Ferrari”    ”<p>Kids Driving Experience, Ferrari.</p>”    ”http://www.udrivecars.com/junior-ferrari.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/1/f1edit-joe_1.jpg”    ”85″    ”No”    ”Ferrari Driving Experiences, Childrens Driving Experiences”    ”new”
“JAM-DM”    ”Junior Aston Martin”    ”<p>Aston Martin drive for Kids.</p>”    ”http://www.udrivecars.com/junior-aston-martin.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/a/s/astedit-joe_1.jpg”    ”85″    ”No”    ”Aston Martin Driving Experiences, Childrens Driving Experiences”    ”new”
“JLAM-DM”    ”Junior Lamborghini”    ”<p>Lamborghini driving for kids.</p>”    ”http://www.udrivecars.com/junior-lamborghini.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/j/u/junlam-edit-dm.jpg”    ”85″    ”No”    ”Lamborghini Driving Experiences, Childrens Driving Experiences”    ”new”
“JRAL-DM”    ”Junior Rally”    ”<p>Rally driving for Kids</p>”    ”http://www.udrivecars.com/junior-rally.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/p/u/pug-dm-edit_1.jpg”    ”75″    ”No”    ”Rally Driving Experiences, Childrens Driving Experiences”    ”new”
“FT-NAT”    ”Ferrari Thrill”    ”<p>Get behind the wheel of the Ferrari 360!</p>”    ”http://www.udrivecars.com/ferrari-thrill-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/1/f1edit-joe_2.jpg”    ”89″    ”No”    ”Ferrari Driving Experiences, View All Driving Experiences”    ”new”
“FE-NAT”    ”Ferrari Experience”    ”<p>Ferrari Thrill &amp; passenger ride, nationwide.</p>”    ”http://www.udrivecars.com/ferrari-experience-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/2/f2edit-joe_1.jpg”    ”99″    ”No”    ”Ferrari Driving Experiences, View All Driving Experiences”    ”new”
“LAT-NAT”    ”Lamborghini Thrill”    ”<p>Drive a Lamborghini, nationwide!</p>”    ”http://www.udrivecars.com/lamborghini-thrill-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lam-edit-joe.jpg”    ”89″    ”No”    ”Lamborghini Driving Experiences, View All Driving Experiences”    ”new”
“LAE-NAT”    ”Lamborghini Experience”    ”<p>Lamborghini Driving Experience, nationwide.</p>”    ”http://www.udrivecars.com/lamborghini-experience-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lam4-edit-joe.jpg”    ”99″    ”No”    ”Lamborghini Driving Experiences, View All Driving Experiences”    ”new”
“SC-NAT”    ”Supercar Experience”    ”<p>Four awesome cars in one fantastic experience! Nationwide</p>”    ”http://www.udrivecars.com/supercar-experience-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/5/f5edit-joe.jpg”    ”229″    ”No”    ”Ferrari Driving Experiences, Supercar Driving Experiences, View All Driving Experiences, Porsche Driving Experiences, Subaru Driving Experiences, Lotus Driving Experiences”    ”new”
“USC-NAT”    ”Ultimate Supercar “    ”<p>Ultimate Supercar Experience, nationwide</p>”    ”http://www.udrivecars.com/ultimate-supercar-experience.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/m/u/multi-edit-joe.jpg”    ”349″    ”No”    ”Ferrari Driving Experiences, Aston Martin Driving Experiences, Lamborghini Driving Experiences, Supercar Driving Experiences, View All Driving Experiences, Porsche Driving Experiences”    ”new”
“LAM-RIDE-OX”    ”Lamborghini Ride”    ”<p>Passenger ride in the spectacular Lamborghini”    ”http://www.udrivecars.com/lamborghini-ride.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lam-edit-joe_2.jpg”    ”75″    ”No”    ”Lamborghini Driving Experiences, Passenger Rides”    ”new”
“R8-PAS-OX”    ”Audi R8 Ride”    ”<p>Audi R8 passenger ride. “    ”http://www.udrivecars.com/audi-r8-ride.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/r/8/r82joe-edit.jpg”    ”75″    ”No”    ”Audi R8 Driving Experiences, Passenger Rides”    ”new”
“AM-RIDE-OX”    ”Aston Martin Ride”    ”<p>Passenger ride in the spectacular Aston Martin!”    ”http://www.udrivecars.com/aston-martin-ride.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/a/s/astedit-joe_2.jpg”    ”75″    ”No”    ”Aston Martin Driving Experiences, Passenger Rides”    ”new”
“FER-PAS-OX”    ”Ferrari Ride”    ”<p>Passenger ride in the spectacular Ferrari! “    ”http://www.udrivecars.com/ferrari-ride.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/5/f5edit-joe_1.jpg”    ”75″    ”No”    ”Ferrari Driving Experiences, Passenger Rides”    ”new”
“AvLa-NAT”    ”Aston Martin v Lamborghini”    ”<p>Drive these two supercars throughout the UK.</p>”    ”http://www.udrivecars.com/aston-martin-v-lamborghini-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/a/v/avla3edit-joe.jpg”    ”199″    ”No”    ”Aston Martin Driving Experiences, Lamborghini Driving Experiences, View All Driving Experiences”    ”new”
“FvAvL-NAT”    ”Ferrari v Aston v Lambo”    ”<p>Drive these supercars at venues throughout the UK with this Nationwide product. “    ”http://www.udrivecars.com/ferrari-v-aston-v-lambo-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lam2010sideedit.jpg”    ”299″    ”No”    ”Ferrari Driving Experiences, Aston Martin Driving Experiences, Lamborghini Driving Experiences, Supercar Driving Experiences, View All Driving Experiences”    ”new”
“AvR-NAT”    ”Aston Martin v Audi R8″    ”<p>Drive these two stunning Supercars nationwide! “    ”http://www.udrivecars.com/aston-martin-v-audi-r8-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/a/s/ast4edit-joe.jpg”    ”199″    ”No”    ”Aston Martin Driving Experiences, Audi R8 Driving Experiences, View All Driving Experiences”    ”new”
“FvR-NAT”    ”Ferrari v Audi R8″    ”<p>Drive both these stunning cars nationwide.”    ”http://www.udrivecars.com/ferrari-v-audi-r8-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/6/f6edit-joe.jpg”    ”199″    ”No”    ”Ferrari Driving Experiences, Audi R8 Driving Experiences, View All Driving Experiences”    ”new”
“LavR-NAT”    ”Lamborghini v Audi R8″    ”<p>Drive both of these Supercars nationwide. “    ”http://www.udrivecars.com/lamborghini-v-audi-r8-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lam4edit-joe.jpg”    ”199″    ”No”    ”Lamborghini Driving Experiences, Audi R8 Driving Experiences, View All Driving Experiences”    ”new”
“FvA-NAT”    ”Ferrari v Aston”    ”<p>Compare these two Supercars nationwide.”    ”http://www.udrivecars.com/ferrari-v-aston-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/a/s/astside.jpg”    ”199″    ”No”    ”Ferrari Driving Experiences, Aston Martin Driving Experiences, View All Driving Experiences”    ”new”
“FvLa-NAT”    ”Ferrari v Lamborghini”    ”<p>Drive the Ferrari & Lamborghini nationwide. “    ”http://www.udrivecars.com/ferrari-v-lamborghini-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/l/a/lam5edit.jpg”    ”199″    ”No”    ”Ferrari Driving Experiences, Lamborghini Driving Experiences, View All Driving Experiences”    ”new”
“FvP-NAT”    ”Ferrari v Porsche”    ”<p>Ferrari & Porsche nationwide.”    ”http://www.udrivecars.com/ferrari-v-porsche-1.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/v/fvp2edit-joe_1.jpg”    ”189″    ”No”    ”Ferrari Driving Experiences, View All Driving Experiences, Porsche Driving Experiences”    ”new”
“SubHalfDay-SW “    ”Subaru RWD Rally Exp, Half Day (Tarmac)”    ”<p>RWD rally fun! “    ”http://www.udrivecars.com/subaru-rwd-rally-exp-half-day-tarmac.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/s/u/sub-tar-subralexp.jpg”    ”185″    ”No”    ”Rally Driving Experiences, Childrens Driving Experiences, View All Driving Experiences, Subaru Driving Experiences”    ”new”
“FullDaySub-SW”    ”Subaru RWD & 4WD Rally Exp, Full Day (Tarmac)”    ”<p>Full day tarmac rally driving.”    ”http://www.udrivecars.com/subaru-rwd-and-4wd-rally-exp-full-day-tarmac.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/s/u/sub-tar3-subralexp.jpg”    ”315″    ”No”    ”Rally Driving Experiences, Childrens Driving Experiences, View All Driving Experiences, Subaru Driving Experiences”    ”new”
“HalfDayEsc-LRS”    ”Escort RWD Rally Exp, Half Day (Gravel)”    ”<p>Rally driving in the classic Ford Escort on a real gravel stage.”    ”http://www.udrivecars.com/escort-rwd-rally-exp-half-day-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/r/a/rallycar.jpg”    ”149″    ”No”    ”Rally Driving Experiences, View All Driving Experiences”    ”new”
“FullDayEsc-LRS”    ”Escort RWD Rally Exp, Full Day (Gravel)”    ”<p>Full day rally on real gravel stage.”    ”http://www.udrivecars.com/escort-rwd-rally-exp-full-day-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file_3_4.jpg”    ”275″    ”No”    ”Rally Driving Experiences, View All Driving Experiences”    ”new”
“MONCARL-LRS”    ”Monte Carlo Half Day (Gravel)”    ”<p>Ford Escort & Subaru Impreza rally driving”    ”http://www.udrivecars.com/monte-carlo-half-day-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/i/m/img_3194.jpg”    ”175″    ”No”    ”Rally Driving Experiences, View All Driving Experiences, Subaru Driving Experiences”    ”new”
“ACROP-LRS”    ”Acropolis Full Day (Gravel)”    ”<p>Escort & Subaru rally driving, full day.”    ”http://www.udrivecars.com/acropolis-full-day-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/i/m/img_3182.jpg”    ”305″    ”No”    ”Rally Driving Experiences, View All Driving Experiences, Subaru Driving Experiences”    ”new”
“SuperSpr-Xtr”    ”Rally Supersprint (Gravel)”    ”<p>Rally driving in Subaru Impreza or Mitsbuishi Evo. “    ”http://www.udrivecars.com/rally-supersprint.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/s/u/sub-gravel-ext.jpg”    ”100″    ”No”    ”Rally Driving Experiences, View All Driving Experiences, Subaru Driving Experiences, Evo Driving Experiences”    ”new”
“SvE-Xtr”    ”Subaru v Evo (Gravel)”    ”<p>Subaru & Evo on gravel. “    ”http://www.udrivecars.com/subaru-v-evo-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/e/v/evo-gravel-2-ext_2.jpg”    ”159″    ”No”    ”Rally Driving Experiences, View All Driving Experiences, Subaru Driving Experiences, Evo Driving Experiences”    ”new”
“RALCHAL-Xtr”    ”Rally Challenge (Gravel)”    ”<p>Half day Rally Experience. “    ”http://www.udrivecars.com/rally-challenge-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/h/y/hyund-multi.jpg”    ”169″    ”No”    ”Rally Driving Experiences, View All Driving Experiences”    ”new”
“EVO-SUPER-XTR”    ”Evo Super Experience (Gravel)”    ”<p>Half Day Evo Driving Experience. “    ”http://www.udrivecars.com/evo-super-experience-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file_9.jpg”    ”205″    ”No”    ”Rally Driving Experiences, View All Driving Experiences, Evo Driving Experiences”    ”new”
“SUB-HALF-XTR”    ”Subaru Super Experience (Gravel)”    ”<P>Subaru Rally Driving, half day.”    ”http://www.udrivecars.com/subaru-super-experience-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/s/u/sub-gravel-ext_2.jpg”    ”205″    ”No”    ”Rally Driving Experiences, View All Driving Experiences, Subaru Driving Experiences”    ”new”
“RALCHALEX-EXTR”    ”Rally Challenge Extra (Gravel)”    ”<p>Full day Hyundai driving. “    ”http://www.udrivecars.com/rally-challenge-extra-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file_9_1.jpg”    ”295″    ”No”    ”Rally Driving Experiences, View All Driving Experiences”    ”new”
“EXTCHAL-XTR”    ”Extreme Challenge (Gravel)”    ”<p>Full day rally driving in Evo & Hyundai. “    ”http://www.udrivecars.com/extreme-challenge-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/f/i/file_12.jpg”    ”359″    ”No”    ”Rally Driving Experiences, Evo Driving Experiences”    ”new”
“JUNRAL-XTR”    ”Junior Rally (Gravel)”    ”<p>Junior Rally Experience on gravel. “    ”http://www.udrivecars.com/junior-rally-gravel.html?SID=visemd0hdvhf8nsliss65rpdp3″    ”http://www.udrivecars.com/media/catalog/product/k/a/ka.jpg”    ”105″    ”No”    ”Rally Driving Experiences, Childrens Driving Experiences”    ”new”

114 Responses to “ Products in Google Shopping Results ”

  1. Toni Anicic
    #1 | 26th March 2010

    Nice, I updated my blog post about Google Base and Magento and added a link to this post as an alternate way.

  2. Rob
    #2 | 26th March 2010

    Hi Toni,

    Thanks very much for your comment, I’ve just had a look at your blog – it’s very good! I look forward to reading your research into magento and e-commerce development.

    Cheers,

    Rob

  3. Stan
    #3 | 26th March 2010

    Does not appear to work when run…

  4. Rob
    #4 | 27th March 2010

    Hi Stan,

    The actual page wont display anything – but the text file should automatically be filled with content – download the txt file and see if it contains your data. Let me know if it doesnt and Ill customise the script for you.

    Cheers,

    Rob

  5. Alan
    #5 | 4th April 2010

    I downloaded the file, ran the script from the browser and it seemed to work. When I inspect the file it appears to have repeated the first url for every product. You can see the results in this file:

    http://twistedtime.com/export/google_base_feed.txt

    You can see this url is repeated for every product:
    http://twistedtime.com/lip-mach-2000-dark-master-watch.html

    I have tried a number of times but always with the same result.

    Any ideas?

  6. Rob
    #6 | 6th April 2010

    Hi Alan,

    Thanks for checking out our blog – I’ve tried accessing your txt file from the URL you provided but it seems the link is down.

    How have you added your products? The script only picks up on products that are visible and enabled so if you could make sure that your products are both for starters.

    If you could send me an email with the contents of your txt file then I’ll try and figure out if its a bug in the script or not.

    Cheers,

    Rob

  7. Sam G. Daniel
    #7 | 8th April 2010

    Rob,

    I tried running the the php file and all I get is that the file can not be found. I created the directory, the blank text file with permission 777. Then added the gbase.php file and I get a 401 error message.

  8. Rob
    #8 | 8th April 2010

    Hi Sam,

    Did you upload the export folder with both files in it – then set the permissions of both files and the folder to 777?

    The 401 just means that like you said the file is unreachable – this may be due to permissions on the gbase.php not being set (by default it might have uploaded with permissions 000 – not even readable).

    Try that out and see what happens

    Cheers,

    Rob

  9. Sam G. Daniel
    #9 | 10th April 2010

    Rob,

    I looked at the permissions for gbase.php and set it to 777 it was 666 before. I still get the 401 error message.

    Thanks

  10. Rob
    #10 | 11th April 2010

    Hi Sam,

    I can see your file is on there – however it seems magento is ignoring it – Have you added anything custom to the magento .htaccess?

    Another thing you could try is to move both files out of the export folder – put them both on the root

    and then change the require_once ‘../app/Mage.php’;

    to

    require_once ‘app/Mage.php’;

    That should remove the possibility of the folder causing problems.

    Give that a go and let me know how you get on – this is an interesting one – also as a test could you put a blank index.php file into that export folder?

    Cheers,

    Rob

  11. judy
    #11 | 28th April 2010

    Invalid price (803 errors)

    We don’t accept non-numeric values, zero (0), or negative prices. If you are including the currency code or symbol, please make sure it matches the currency of the target country.
    Examples:
    Examples:
    Item Nr. Line Nr. Value
    271 272 “26.9900″
    349 350 “29.9900″
    558 559 “29.9900″
    639 640 “44.9900″
    759 760 “26.9900″

    this is what google base tells me, i guess it doesnt like the 00 at end of prices? is there a way to remove this?

  12. Rob
    #12 | 28th April 2010

    Hi Judy,

    The easiest way to get rid of that would be to do a find-replace on your .txt file – using word or notepad. Just replace-all 00″ with nothing – this should remove the 00 off all of them.

    However with a few of our test google accepted the following:

    “certikin_sfsc05/2″ “5 Ltr Spring Cleaner (Acid Wash)” “

    • Removes staining and scaling from pool surfaces.
    • Effective on all types of pool surfaces.
    • No unpleasant odour.

    ” “http://www.xxxx.co.uk/5-ltr-spring-cleaner.html” “http://www.xxxx.co.uk/media/catalog/product/s/p/spring_cleaner.jpg” “25.8500″ “No” “Special Application Products” “new”

    So if your results follow these then it should be ok – however make sure that you have no empty fields at the bottom of your txt file and also make sure that you have inclluded all of the above (the rows are:)

    id title description link image_link price brand product_type condition

  13. judy
    #13 | 2nd May 2010

    Hi

    Thanks for your answer, i added this to the code:

    $product_data['price']= round($product->getPrice(),2);

    slightly modified one of your lines so it rounds price to 2 decimal places

    works fine now :)

  14. Judy
    #14 | 5th May 2010

    Hello
    Im trying to use this script to export the products with the quantities aswell.
    I added the following code:
    $product_data['title']=$product->getQty();
    I also added Qty to the array

    When i run this though i get a Qty column but it is empty.

    I also tried exporting things like size etc but i get the same problem empty columns.
    am i doing something wrong here?

    thank you

  15. Rob
    #15 | 6th May 2010

    Hi Judy,

    The reason why the stock levels aren’t showing is because the getQty() method is in a different model.
    I have edited the code as you have it to incorporate the price change and also the qty.


    < ?php
    define('SAVE_FEED_LOCATION','google_base_feed.txt');

    set_time_limit(0);

    require_once '../app/Mage.php';
    Mage::app('default');

    try{
    $handle = fopen(SAVE_FEED_LOCATION, 'w');

    $heading = array('id','title','description','link','image_link','price','brand','product_type','condition','qty');
    $feed_line=implode("\t", $heading)."\r\n";
    fwrite($handle, $feed_line);

    //---------------------- GET THE PRODUCTS
    $products = Mage::getModel('catalog/product')->getCollection();
    $products->addAttributeToFilter('status', 1);
    $products->addAttributeToFilter('visibility', 4);
    $products->addAttributeToSelect('*');
    $prodIds=$products->getAllIds();

    $product = Mage::getModel('catalog/product');

    foreach($prodIds as $productId) {

    $product->load($productId);

    $product_data = array();
    $product_data['sku']=$product->getSku();
    $product_data['title']=$product->getName();
    $product_data['description']=$product->getShortDescription();
    $product_data['link']=$product->getProductUrl();
    $product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
    $product_data['price']= round($product->getPrice(),2);

    $product_data['brand']=$product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);
    $product_data['product_type']='';
    $product_data['condition']="new";
    $product_data['qty']=(int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();

    foreach($product->getCategoryIds() as $_categoryId){
    $category = Mage::getModel('catalog/category')->load($_categoryId);
    $product_data['product_type'].=$category->getName().', ';
    }
    $product_data['product_type']=rtrim($product_data['product_type'],', ');

    foreach($product_data as $k=>$val){
    $bad=array('"',"\r\n","\n","\r","\t");
    $good=array(""," "," "," ","");
    $product_data[$k] = '"'.str_replace($bad,$good,$val).'"';
    }

    $feed_line = implode("\t", $product_data)."\r\n";
    fwrite($handle, $feed_line);
    fflush($handle);

    }

    fclose($handle);

    }
    catch(Exception $e){
    die($e->getMessage());
    }

    This should bring your QTY back just fine – I see Google have adopted stock levels into their shopping – this either escaped me the first time or its new!

    Hope this helps,

    Rob

  16. Simon
    #16 | 25th May 2010

    Is it possible for the script to create mulitple feed files rather than just one. e.g less than 15mb each to meet the Gbase requirement.

  17. Rob
    #17 | 25th May 2010

    Hi Simon,

    It is possible, you would have to modify the foreach statement to create multiple files, the easiest way to do this would probably be to duplicate the gbase.php file so you have gbase.php and gbase2.php.

    You can then modify gbase2.php so that it writes to a file called
    google_base_feed2.txt

    The foreach you can then make into a For statement.

    So basically if you change the top foreach from:

    foreach($prodIds as $productId) {

    to something like:

    for($i=0; $i<500;$i++){

    then all $productId within this loop should be changed to $prodIds[$i]

    in the second gbase you can then do for($i=501; $i<1000;$i++){

    which would write the next 500 to the second file. you could repeat this many times over.

    Cheers,

    Rob

  18. Hamish
    #18 | 9th June 2010

    Hi all,

    Firstly, thank you to Rob for writing and sharing his script, I am sure we all appreciate it.

    It was just to let you know that I have 3 stores running the latest version of Magento (1.41) and when I ran the script, I got one URL for all of my products and it wrote my first category name for everything. I also had the price issue highlighted above but Judy’s round solution only works for products that have 2 figures after the decimal place. If you want 100.00, it rounds the number to 100 and Google Base will not accept the format.

    I have now amended Rob’s script slightly and it’s working great for me now so I thought I would share it.

    1. URL

    Replace

    $product_data['link']=$product->getProductUrl();

    with

    $product_data['Deeplink']=”http://www.domain.com/”.$product->getUrlPath();

    Don’t forget to change the domain.com to yours!!

    2.

    As my stores are related to just one product type category, I have used Googles product type list and selected the appropirate product type related to my store – list is here:

    http://www.google.com/support/merchants/bin/answer.py?answer=160081&hl=en_GB

    and removed the category foreach loop and inserted the text that I wanted to assign the product type to using this bit of code.

    $product_data['product_type']=’**product id here**’;

    I appreciated that it would be better to be more defined but it works for me!

    Finally to the price. As mentioned above, if you use the round code, it also gets rid of the 00 after the decimal point and Google rejects it – it did to me on 3 accounts.

    So, replace:

    Original: $product_data['price']=$product->getPrice();
    or
    Round: $product_data['price']= round($product->getPrice(),2);

    with this:

    $product_data['price']=number_format($product->getPrice(), 2);

    I hope that helps someone else out.

    Hamish

  19. Robert Kent
    #19 | 10th June 2010

    Thank you Hamish for these amendments – thats the beauty of open source :)

  20. Hamish
    #20 | 10th June 2010

    Hi Rob,

    You are more than welcome – I appreciate you writing and sharing the original code – bit of a hacker myself I’m afraid!!

    Incidentally, if anyone wants rid of any html in the description, change:

    $product_data['description']=$product->getShortDescription();

    to

    $product_data['description']=strip_tags($product->getShortDescription());

    Have fun,

    H

  21. Neil Bradley
    #21 | 17th June 2010

    Interesting one. I had the same issue as Sam, the gbase.php just kept erroring with a 404 message. I decided to reupload the export folder and the files inside, but leaving the permissions as 755 for the folder and 644 for the php and txt files.

    Guess what? It worked. :D

    The only trouble then was that I got the Allowed memory size of 67108864 bytes exhausted. :(

  22. John B
    #22 | 30th June 2010

    Hi, thank you for your script, I wish I could get it to work,

    I am using latest version of magento and cannot seem to get the Magento google base to work, keep getting the following error,

    Expected response code 200, got 400. Type: data. Field: title. Reason: Title is required.. Type: data. Field: description. Reason: The attribute is invalid.

    Also get this error when trying to use your script.

    Fatal error: Uncaught exception ‘Mage_Core_Model_Store_Exception’ in /home/hamps/public_html/app/code/core/Mage/Core/Model/App.php:1228 Stack trace: #0 /home/hamps/public_html/app/code/core/Mage/Core/Model/App.php(760): Mage_Core_Model_App->throwStoreException() #1 /home/hamps/public_html/app/Mage.php(322): Mage_Core_Model_App->getStore(NULL) #2 /home/hamps/public_html/app/Mage.php(334): Mage::getStoreConfig(‘web/url/use_sto…’, NULL) #3 /home/hamps/public_html/app/code/core/Mage/Core/Controller/Request/Http.php(196): Mage::getStoreConfigFlag(‘web/url/use_sto…’) #4 /home/hamps/public_html/app/code/core/Mage/Core/Controller/Request/Http.php(148): Mage_Core_Controller_Request_Http->_canBeStoreCodeInUrl() #5 /home/hamps/public_html/app/code/core/Mage/Core/Model/App.php(379): Mage_Core_Controller_Request_Http->setPathInfo() #6 /home/hamps/public_html/app/code/core/Mage/Core/Model/App.php(262): Mage_Core_Model_App->_initRequest() #7 /home/hamps/public_html/app/Mage.php(570): Mage_Core_Model_App->i in /home/hamps/public_html/app/code/core/Mage/Core/Model/App.php on line 1228

    Your help would be much appreciated as getting desperate to get this working

    Thanks

    John

  23. Robert Kent
    #23 | 30th June 2010

    Hi John B,

    It seems that google base is trying to generate the list – but there may be things missing in your products or invalid characters in your title/description. There may have been changes since this script which works with 1.3.2.1 tested and is apparently working in 1.4.0.1. I know 1.4.1.0 has changes dramatically so I will look into updating this script.

    However I would have hoped that magento would have sorted out its own google base method by now – do you get the same error using magento’s built in? Also if its a scheduled task make sure you set it up with a cron job.

  24. Chris
    #24 | 1st July 2010

    I am having the same problems as another user, the product URL is the same for all of the products. All of the other fields come out correctly but the URL shows the same for all of them.

  25. Neil Bradley
    #25 | 4th August 2010

    For some reason google still complains about the prices being invalid in my script. I’ve tried using the original method, round and number_format. These are examples that google does not like;

    Item Nr. Line No. Value
    111 112 “89.99″
    132 133 “49.99″
    190 191 “79.99″
    254 255 “99.99″
    318 319 “49.99″

    Just don’t understand it. :S

  26. Robert Kent
    #26 | 5th August 2010

    Hi Neil,

    I can fix that for you

  27. Neil Bradley
    #27 | 6th August 2010

    Hey everyone,

    Robert very kindly sent me a fix for doing a string replace on all ” in the exported txt file. This obviously works, but in my case I wouldn’t want a client to have to do this each time they need to update Google Base.

    A neat solution is to go into the Google Base settings for your data feed in the Google Merchant Center. There is an option there to “Use Quoted Fields”. This easily solves the problem I was having with prices, so it may be of use to others who were facing similar troubles with prices.

  28. Caldera Mike
    #28 | 10th August 2010

    Brilliant script, been looking for something like this since discovering the built in Magento system doesnt work that well, MANY thanks, saved me hours of work :)

  29. usho
    #29 | 17th August 2010

    On Magento 1.4.1 i am having trouble…
    Fatal error: Call to a member function getFrontend() on a non-object in /var/www/virtual/shopfolder/htdocs/export/gbase.php on line 47

  30. Anthony
    #30 | 2nd September 2010

    I am having a similar issue to Alan, it works perfectly but the URL for all products is the same as the first one.

    Any ideas?

  31. Anthony
    #31 | 2nd September 2010

    @Usho

    I had similar problems. open up the file line 47 should be product_type make sure you didn’t rename that in your magento backend. I renamed manufacturer to brand in my backend so I had to make the same change to the php file.

  32. Peter Jones
    #32 | 6th September 2010

    Hi, great script. I also have the problem that all my items have the same URL appearing in the code.

    Thanks

    id title description link image_link price brand product_type condition

    “ANT01″ “Antirrhinum (Snapdragon) Brighton Rock” “An heirloom variety, perhaps in cultivation for over a hundred years, this unusual and attractive Snapdragon produces pastel and bicolored blooms, the majority overlaid with blotches and stripes of contrasting colours. A conspicuous and showy plant for the garden and certainly that little bit different. An excellent cut flower. If you have any questions or comments about this product please contact us by clicking here. Approx 700 seeds per pack. ” “http://www.simplysowseeds.co.uk/antirrhinum-brighton-rock.html” “http://www.simplysowseeds.co.uk/media/catalog/product/a/n/ant001.jpg” “0.9″ “No” “Flower Seeds, Flowers A – C” “new”

    “ANT02″ “Antirrhinum (Snapdragon) Monarch Rust Resistant Mixed” “Specifically bred for the amateur home gardener who likes to raise his own plants from seed is this fine, medium-sized Snapdragon which, at the same time, is highly resistant to that curse of the breed, Antirrhinum rust. The mixture comes in a wide variety of colours such as amber, coral, crimson and orange. 16-18 ins. If you have any questions or comments about this product please contact us by clicking here. Approx 700 seeds per pack.” “http://www.simplysowseeds.co.uk/antirrhinum-brighton-rock.html” “http://www.simplysowseeds.co.uk/media/catalog/product/a/n/ant002_2.jpg” “0.85″ “No” “Flower Seeds, Flowers A – C” “new”

    “SWE001″ “Sweet Pea Bouquet Mixed” “Sweet Pea Bouquet has large, bright blooms on long sturdy stems, great for shows. A vigorous grower and one of the best for cut flowers. 24 Seeds” “http://www.simplysowseeds.co.uk/antirrhinum-brighton-rock.html” “http://www.simplysowseeds.co.uk/media/catalog/product/s/w/swe001_1_1.jpg” “1.2″ “No” “Flower Seeds, Flowers A – C” “new”

  33. Peter Jones
    #33 | 6th September 2010

    Sorry, should have mentioned that my text file is at:

    http://www.simplysowseeds.co.uk/export/google_base_feed.txt

  34. Robert Kent
    #34 | 8th September 2010

    Hi Peter,

    Have you tried doing what hamish suggested below:

    Replace

    $product_data['link']=$product->getProductUrl();

    with

    $product_data['Deeplink']=”http://www.domain.com/”.$product->getUrlPath();

    Don’t forget to change the domain.com to yours!!

    This might sort out your problem. If not let me know!

  35. Peter Jones
    #35 | 9th September 2010

    Thanks for that. I now get:

    Parse error: syntax error, unexpected ‘:’ in /home/simplys1/public_html/export/gbase.php on line 42

    The full script is now:

    getCollection();
    $products->addAttributeToFilter(‘status’, 1);//enabled
    $products->addAttributeToFilter(‘visibility’, 4);//catalog, search
    $products->addAttributeToSelect(‘*’);
    $prodIds=$products->getAllIds();

    //echo ‘Product filter: ‘.memory_get_usage(false).”;
    //flush();

    $product = Mage::getModel(‘catalog/product’);

    foreach($prodIds as $productId) {
    //echo ‘. ‘;
    //flush();
    //echo ‘Loop start: ‘.memory_get_usage(false).”;
    //flush();

    //$product = Mage::getModel(‘catalog/product’);
    $product->load($productId);

    $product_data = array();
    $product_data['sku']=$product->getSku();
    $product_data['title']=$product->getName();
    $product_data['description']=$product->getShortDescription();
    $product_data['Deeplink']=”http://www.simplysowseeds.co.uk/”.$product->getUrlPath();
    $product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).’catalog/product’.$product->getImage();
    $product_data['price']= round($product->getPrice(),2);

    $product_data['brand']=$product->getResource()->getAttribute(‘manufacturer’)->getFrontend()->getValue($product);
    $product_data['product_type']=”;
    $product_data['condition']=”new”;

    //echo ‘Product load: ‘.memory_get_usage(false).”;
    //flush();

    //get the product categories
    foreach($product->getCategoryIds() as $_categoryId){
    $category = Mage::getModel(‘catalog/category’)->load($_categoryId);
    $product_data['product_type'].=$category->getName().’, ‘;
    }
    $product_data['product_type']=rtrim($product_data['product_type'],’, ‘);

    //echo ‘Category load: ‘.(memory_get_usage(false)).”;

    //sanitize data
    foreach($product_data as $k=>$val){
    $bad=array(‘”‘,”\r\n”,”\n”,”\r”,”\t”);
    $good=array(“”,” “,” “,” “,”");
    $product_data[$k] = ‘”‘.str_replace($bad,$good,$val).’”‘;
    }

    $feed_line = implode(“\t”, $product_data).”\r\n”;
    fwrite($handle, $feed_line);
    fflush($handle);

    //echo ‘Loop end: ‘.memory_get_usage(false).”;
    //flush();
    }

    //———————- WRITE THE FEED
    fclose($handle);

    }
    catch(Exception $e){
    die($e->getMessage());
    }

  36. Peter Jones
    #36 | 9th September 2010

    I have just tried removing the http:// from the line so it becomes

    $product_data['Deeplink']=”www.simplysowseeds.co.uk/”.$product->getUrlPath();

    The script now runs but the export file exports the URLS as

    “”wwwsimplysowseedscocanterbury-bells-cup-and-saucer-mix.html” (Note the extra “, and the lack of ,co.uk and the missing .

    Thanks

  37. Peter Jones
    #37 | 9th September 2010

    I think I may have fixed it…

    If you change the double quote to single quote it works. My Ladybird (Anyone old enough to remember those) book of PHP really helped!

    $product_data['Deeplink']=”http://www.simplysowseeds.co.uk/”.$product->getUrlPath();

    Becomes:

    $product_data['Deeplink']=’http://www.simplysowseeds.co.uk/’.$product->getUrlPath();

  38. Henry Bugleton
    #38 | 24th September 2010

    I submitted a data feed to Merchant but it was rejected because of a duplicate link attribute. I think it’s penalising my site for having the same product but in a different colour on the same page, what’s the best way around this?

  39. Fresh Purple
    #39 | 27th September 2010

    Thanks Hamish – I was getting the same url problem as well and your fix worked perfectly for me.

    I am having the same problem with the foreach loop though – it’s getting the categories for the first product and then using that for all of them! At least I have something I can upload though now, even if they are all apparently “Purple Amethyst Earrings”!

  40. phil
    #40 | 5th October 2010

    Is there anyway that i can get the special prices rather than the RRP? would save me a lot of hassle
    thanks phil

  41. Chris
    #41 | 5th October 2010

    This only lists simple products. Many of my products are grouped. A grouped product record doesn’t have a price. Is there anyway to grab the grouped product with the lowest priced associated/child simple product?

    Any help would be appreciated.

  42. Flipmedia
    #42 | 9th October 2010

    schedule it amendment…

    I prefer a more hands free approach so I amended the very useful script published by Robert so the contents of the file google_base_feed.txt is feed straight back after the script call with the correct text/plain header… So after performing a Manual Upload you may configure a scheduled upload using the following URL…

    http://www.your-domain.com/export/gbase.php/google_base_feed.txt

    The end part “/google_base_feed.txt” does nothing apart from keep Google happy…

    Hope this helps someone and thank Robert for publishing the script in the first instance…

    getMessage());
    }

    if (!file_exists(SAVE_FEED_LOCATION)) {
    header(“HTTP/1.0 404 Not Found”); // Return not found if feed file does not exist
    } else {
    header(“Content-Type: text/plain”); // Set text header
    print(file_get_contents(SAVE_FEED_LOCATION)); // output content of feed file
    }
    exit();
    ?>

    I used “file_get_contents” as I only have to deal with around 500 products… you may want to read the file in chunks if you have more products…

  43. Robert Kent
    #43 | 12th October 2010

    Thank you all for your contributions to this script – I have edited it slightly to include hamish’s suggestion – I have changed it slightly so that you do not need to add your own url so its still a copy and paste jobby. Thanks Flipmedia for the comment above I’ll look into this automation.

    Cheers,

    Rob

  44. Tim Pearson
    #44 | 14th October 2010

    I had the same problem as John B.

    Just need to change line 8:
    Mage::app(‘default’);

    to:
    Mage::app();

  45. Tim Pearson
    #45 | 14th October 2010

    The categories weren’t loading correctly for me, I was just getting the first category repeat through all the products, changing:
    foreach($product->getCategoryIds() as $_categoryId){

    to:
    foreach(Mage::getResourceSingleton(‘catalog/product’)->getCategoryIds($product) as $_categoryId){

    fixed it.

    Cheers,
    Tim

  46. Oliver Gibson
    #46 | 18th October 2010

    Hi, i am having a problem with the code i am not getting the correct url to the product. my base file is

    http://www.ojsports.co.uk/export/google_base_feed.txt

    and i am getting like that are http://www.ojsports.co.uk/gbase.php/yonex-nanogy-95.html with the gbase.php within them which is incorrect

  47. Robert Kent
    #47 | 18th October 2010

    Hi Oliver,

    That doesn’t look right at all! You should try something like this:

    $product_data['Deeplink']=”http://”.$_SERVER['HTTP_HOST'].”/”.str_replace(“gbase.php/”, “”, $product->getUrlPath()); // thanks to hamish for this

    In your particular case this should get rid of that gbase.php/ for you – give it a go and let me know how you get on.

  48. joan
    #48 | 7th December 2010

    I tried this it works but it doesn’t export all products. Any idea?

  49. Ace Winget
    #49 | 22nd December 2010

    Does anyone know if there is any way to add more attributes to the code instead of pulling just the minimum required google headers.

  50. Chris
    #50 | 28th January 2011

    Thanks for this script!

    It’s rather sad that the magento team hasn’t paid more attention to this. I was excited to see Merchant Center (Base) integrated directly into the cart – however, using it has been a bit of nightmare (I keep getting “Expected response code 200, got 403. Type: request. Reason: Could not find authenticated customer.” when trying to add product to GB through Magento and have yet to find a fix). This alternative method for submitting products to Merchant Center is nice. I do have an issues running the gbase.php file though. I can visit the URL fine, and the script starts running (http://www.shubee.com/export/gbase.php). However after a few seconds I receive an HTTP 500 Error. I checked the google_base_feed.txt file and there are about 200 products listed in it successfully despite the error. I also have no problem with the generated file when I submit it in the Merchant Center.

    It also appears that this script is only pulling information for simple products. Is it possible to include configurable products with this?

    All my best,

    -chris

  51. Andrew
    #51 | 19th February 2011

    hey there,
    thanks for the script!
    it’s sitting there and processing now, but much better that the stock Magento functionality, which kept erroring out.

    you’ve saved me a lot of time!

    Andrew

  52. Robert Kent
    #52 | 22nd February 2011

    Hi Andrew,

    You’re right – the stock magento one gives up at every error (bad character in descripton etc) – I hope they sort it out soon! But until then this script does the job

  53. Robert Kent
    #53 | 22nd February 2011

    Hi chris, It does seem to pull info for configurable products for me – the only filters are visiblity and enabled – check to make sure your configurable products are set to Catalog, Search visibility

  54. Ignacio
    #54 | 22nd February 2011

    I too am having troubles with the categories. It seems to be repeating the same category over and over onto all of my products.

    Anyone have a good fix for this?

  55. Todd
    #55 | 3rd March 2011

    Hello,

    Thanks for this script! Unfortunately I’m not getting any products populated into the google_base_feed.txt file. What could I be doing wrong?

    Thanks.

  56. Ben McManus
    #56 | 4th March 2011

    @Todd Here are a few tips to help you with debugging:

    Try checking your permissions for google_base_feed.txt and the parent folder (should be 777)

    also the the top of gbase.php add the following lines of code to display any PHP errors

    display_errors(E_ALL);
    ini_set('display_errors',1);
    

    Ben

  57. Todd
    #57 | 8th March 2011

    Hi Ben,

    I had my host make sure the files and folder had the right permissions and I added that code to the gbase.php file. Still, when I run it, I don’t get any info in this file http://dev.airtronics.net/export/google_base_feed.txt

    My host says the gbase.php file doesn’t look complete to them. Any suggestions?

    Thanks,

    Todd

  58. Robert Kent
    #58 | 9th March 2011

    Hi Todd,

    Can you try downloading the zip file rather than copying the php from the text? That should ensure the file is completely accurate

  59. Todd
    #59 | 9th March 2011

    Thanks,

    I did that. The only thing that is being written is the header inf as you can see here http://dev.airtronics.net/export/google_base_feed.txt

    Any other ideas?

    Thanks

  60. Dmitry
    #60 | 10th March 2011

    Hi.

    I installed export folder as per instructions but when i try to run the script through the browser i get:

    Fatal error: Uncaught exception ‘Mage_Core_Model_Store_Exception’ in /home/myrugsto/public_html/app/code/core/Mage/Core/Model/App.php:1228 Stack trace: #0 /home/myrugsto/public_html/app/code/core/Mage/Core/Model/App.php(760): Mage_Core_Model_App->throwStoreException() #1 /home/myrugsto/public_html/app/Mage.php(322): Mage_Core_Model_App->getStore(NULL) #2 /home/myrugsto/public_html/app/Mage.php(334): Mage::getStoreConfig(‘web/url/use_sto…’, NULL) #3 /home/myrugsto/public_html/app/code/core/Mage/Core/Controller/Request/Http.php(196): Mage::getStoreConfigFlag(‘web/url/use_sto…’) #4 /home/myrugsto/public_html/app/code/core/Mage/Core/Controller/Request/Http.php(148): Mage_Core_Controller_Request_Http->_canBeStoreCodeInUrl() #5 /home/myrugsto/public_html/app/code/core/Mage/Core/Model/App.php(379): Mage_Core_Controller_Request_Http->setPathInfo() #6 /home/myrugsto/public_html/app/code/core/Mage/Core/Model/App.php(262): Mage_Core_Model_App->_initRequest() #7 /home/myrugsto/public_html/app/Mage.php(570): Mage_Core_Model_App->i in /home/myrugsto/public_html/app/code/core/Mage/Core/Model/App.php on line 1228

    Any ideas?

    Many Thanks.

    Dmitry

  61. Ben
    #61 | 10th March 2011

    Hi Todd/Dmitry

    It looks like the gbase.php file is looking for a store that doesn’t exist.

    On line 8(ish) of gbase.php there is:

    Mage::app('default');
    

    change that line to the following:

    Mage::app();
    
    OR
    
    Mage::app('<YOUR_STORE_NAME_HERE>');
    

    That should get rid of the uncaught exception error.

    Ben

  62. Dmitry
    #62 | 10th March 2011

    Hi Ben.

    Thanks for your prompt reply.

    I have changed line 8 to Mage::app(); but now get the following error:

    Fatal error: Call to a member function getFrontend() on a non-object in /home/myrugsto/public_html/export/gbase.php on line 49

    Many thanks for your help.

    Dmitry.

  63. Ben McManus
    #63 | 10th March 2011

    Hi Dmitry,

    I think you need to call your store in the Mage::app() method.

    Login to your admin panel and navigate to System -> Manage Stores. Copy the store name you want to export products to google with and paste it into your app() as a parameter. EG Mage::app(”);

    Do you know what version of Magento are you using?

  64. Dmitry
    #64 | 10th March 2011

    I’m using 1.4.01. In System -> Manage Stores i see the following:

    Website Name: Main Website
    Store Name: Main Website Store
    Store View: English

    I tried adding all of these and i still get an error with any of these names.

    Fatal error: Uncaught exception ‘Mage_Core_Model_Store_Exception’ in /home/myrugsto/public_html/app/code/core/Mage/Core/Model/App.php:1228 Stack trace: #0 /home/myrugsto/public_html/app/code/core/Mage/Core/Model/App.php(760): Mage_Core_Model_App->throwStoreException() #1 /home/myrugsto/public_html/app/Mage.php(322): Mage_Core_Model_App->getStore(NULL) #2 /home/myrugsto/public_html/app/Mage.php(334): Mage::getStoreConfig(‘web/url/use_sto…’, NULL) #3 /home/myrugsto/public_html/app/code/core/Mage/Core/Controller/Request/Http.php(196): Mage::getStoreConfigFlag(‘web/url/use_sto…’) #4 /home/myrugsto/public_html/app/code/core/Mage/Core/Controller/Request/Http.php(148): Mage_Core_Controller_Request_Http->_canBeStoreCodeInUrl() #5 /home/myrugsto/public_html/app/code/core/Mage/Core/Model/App.php(379): Mage_Core_Controller_Request_Http->setPathInfo() #6 /home/myrugsto/public_html/app/code/core/Mage/Core/Model/App.php(262): Mage_Core_Model_App->_initRequest() #7 /home/myrugsto/public_html/app/Mage.php(570): Mage_Core_Model_App->i in /home/myrugsto/public_html/app/code/core/Mage/Core/Model/App.php on line 1228

    Thanks.

  65. Dmitry
    #65 | 10th March 2011

    I think i got it, well sort of :)

    Looking at the error when using Mage::app(”); it says there is a problem on line 49. Line 49 is calling for brand attribute which i don’t have in my store. So I commented it out and the script seems to run but now i get:

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /home/myrugsto/public_html/lib/Zend/Db/Select.php on line 744

    Thanks.

  66. Robert Kent
    #66 | 10th March 2011

    Hi Dmitry,

    Thats good – this error is easy to fix. Find your .htaccess and go to line 34 or thereabouts – you will see a php_value memory_limit 64M or 128M. Try setting this higher – this will give your domain more memory to allocate to this task.

    Try setting it to 128M if its currently at 64M. If it has a # before hand that means it’s commented out – remove that # and the value will be set.

    If its at 128M set it to 256M.

    Cheers,

    Rob

  67. Dmitry
    #67 | 10th March 2011

    Hi Rob.

    I set it to 256M but it does not seem to have any effect. Still getting the same error. In google_base_feed.txt only 169 products are generated.

    I’m sorry to be a pain.

    Your help is much appreciated.

    Dmitry.

  68. Robert Kent
    #68 | 10th March 2011

    Hi Dmitry,

    Your htaccess is looking correct. However the change has not been applied – the error you are getting is

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /home/myrugsto/public_html/lib/Zend/Db/Select.php on line 744

    The total number of bytes above is 64M – your default memory limit.

    There are 2 things you can try.

    1. Try moving the php_value memory_limit 256M to the absolute bottom of you .htaccess file – after everything then try again.
    2. Contact your hosting company to modify the memory limit in the php.ini to 256M.

    Hope this helps!

    Cheers,

    Rob

  69. Dmitry
    #69 | 10th March 2011

    Hi Rob.

    I have finally got it to work. Contacted my hosting provider and they set memory limit in php.ini.

    Huge thanks for your patience and help. Great blog. Will deffinetly recomend to everyone I know.

    Kind Regards,

    Dmitry.

  70. Robert Kent
    #70 | 10th March 2011

    Hi Dmitry – You’re very welcome! All of Us will do what we can to help any magento developer.

  71. Todd
    #71 | 16th March 2011

    Hi guys,

    Thanks for all the information. I’m finally getting some results, but weird things are happening with the txt file. I have 17,000 sku’s, but only 4862 are being written to the file. Also, the price seems to get stuck and writes the same value for a bunch of the skus, which is a problem as that isn’t the correct price of the item.

    Any ideas?

    Thanks

  72. Keith
    #72 | 19th March 2011

    Thanks for this script but I cannot get it to write the file – it just writes the one line of headers and no product data. I have checked setup and looked at the other comments and it looks OK. I am not getting any error message displayed.

    It is currently using the gbase.php direct from your zip file but I have tried changing line 8 from
    Mage::app(‘default’); // or use Mage::app(); for later versions of magento
    to
    Mage::app()
    and
    Mage::app(‘Internet Golf Store’)
    with no change to the results.
    I would appreciate any help you can offer
    Best wishes, Keith

  73. ricky
    #73 | 30th March 2011

    hi,
    Great article!
    i tried to upload txt file into google base but no luck. the error getting like Uploaded on Mar 30, 2011 2:17 pm PDT
    0 of 1 items inserted – Processed on Mar 30, 2011 2:17 pm PDT

    Total File Size: 1.36 KB
    Detected attribute language: English
    Detected encoding: UTF-8
    Detected delimiter: Tab (\t)
    Detected file format: Text

    how can i fixed this? also in the google product shopping how i can add comparable option.from the magneto back-end the product uploaded to merchant while the product search not working.
    –though i uploaded to google base for the osc site like http://www.islamicapproach.com but not getting magento.

    thanks

  74. kyle
    #74 | 8th April 2011

    Hi Rob,

    Great blog! I am trying to get this working but I keep getting a 404. I have set the permissions for the files and the folder, as well as putting the files straight in the root. All with the same result. I have a feeling it has to do with .htaccess cause that file has been heavily modified. I am not sure what I am looking for in there. Any help would be appreciated!

    Thanks

  75. ricky
    #75 | 10th April 2011

    After tweak successfully uploaded google merchant and google base. also product is showing in the google product search though after few days later not showing in the product search and ensuring the time is not over!

    thanks

  76. Rick
    #76 | 5th May 2011

    great script. any way to limit to simple products? i tried adding this filter, but “type” is not recognized?

    $products->addAttributeToFilter(‘type’, simple);//only simple

    i don’t want to list grouped products in my feed.

    thanks.

  77. Rick
    #77 | 5th May 2011

    …limit to simple products correct filter. solved.

    $products->addAttributeToFilter(‘type_id’, ‘simple’);//only simple products

  78. Mark at Blazen Web Marketing
    #78 | 7th May 2011

    Thanks Rob for this script, it really does a great job to get around the deficiencies of Magento’s method.

    I’ve implemented the script today and all my categories were identical in the txt file, which they shouldn’t be. I implemented Tim Pearson’s fix which worked. I assume it would make sense to add this to your main script? Here’s what he says below:
    ________________________________________________________________

    “The categories weren’t loading correctly for me, I was just getting the first category repeat through all the products, changing:
    foreach($product->getCategoryIds() as $_categoryId){
    to:
    foreach(Mage::getResourceSingleton(‘catalog/product’)->getCategoryIds($product) as $_categoryId){
    fixed it.
    Cheers,
    Tim
    __________________________________________________________________

  79. Toby
    #79 | 10th May 2011

    How do you get grouped products to work? They currently add to the txt file but displays a 0 price, if I set the visibiliy of the simple products it will display a random price from there but when you click the link in Google it will go to the simple product page and not the group product page.

  80. Lancelot
    #80 | 13th May 2011

    Amazing script! Saved me hours of manually mapping attributes for my 18 Attribute Sets! Nice thing is the ability to easily add more attributes if needed. Thanks!

  81. Lombar
    #81 | 17th May 2011

    My website is usign magento 1.5. I tryed your script at my local server and doesn’t work. No errors, but nothing is written on txt file.
    And I tryed on production, and same problem.

    I tryed
    Mage::app(‘default’)
    Mage::app(”)
    Mage::app()
    Mage::app(‘torrevinos’)
    Mage::app(‘tienda torrevinos’)

    And 777 is set, of course. Anybody can help me?
    It’s important because Google Merchant now is working at Spain, but Magento Google Api doesn’t support my country. I can upload my products to Google Merchant using Magento Control Panel, but my products are showed to people at UK or Germay, but not at Spain.

    Thanks in advanced.

  82. pete
    #82 | 26th May 2011

    Hey there – Just a quick one to say I’ve modified this scripted slightly to get the link working in a way that could be better for SEO. ie no duplicate content…

    Under

    foreach($prodIds as $productId) {

    Add

    $product->load($productId);

    $_categories = $product->getCategoryCollection();
    $_category = null;
    foreach($_categories as $_cat){
    if(is_null($_category) || $_cat->getLevel() > $_category->getLevel()){
    $_category = $_cat;
    }
    }

    $productUrl = (!is_null($_category)) ? $_category->getUrl().’/’.basename($product->getProductUrl()) : $product->getProductUrl();
    $productUrl = str_replace(‘/index.php’, ”, $productUrl);

    Replace

    $product_data['Deeplink']=”http://”.$_SERVER['HTTP_HOST'].”/”.$product->getUrlPath(); // thanks to hamish for this

    with

    $product_data['Deeplink']=$productUrl; // thanks to hamish for this

  83. Rick
    #83 | 7th June 2011

    This is very useful. I tweaked it to add weight by adding:

    $product_data['weight']=$product->getWeight();

    and adding ‘weight’ in the heading array.

    Has anyone used this with tiered pricing? We set the “Price” to manufacturer’s list and the “Special Price” to our selling price for most items. For some items we used the Tiered Prices which now come out at “Price”. There is a “Minimal Price” attribute that seems to reference the lowest tier price, but I can’t figure out how to access it.

  84. Robert Kent
    #84 | 9th June 2011

    For those of you looking to add group products or having problems with configurable products with a 0 base price – try changing getPrice to getFinalPrice. I’ll be re-writing this pretty shortly to accomodate all contributions here in the comments – thank you all for contributing :)

  85. Patrick
    #85 | 1st July 2011

    Hey, just want to say thank you for this great script and the helpful comments as well. It saves me a lot of trouble and does what it should do. Great effort!

  86. Greg
    #86 | 6th July 2011

    Thanks for a great way to submit a feed not only to google base but, the find, and frogit.. They all use the same product format.

    The only problem I’m having is: In the brand columm, the script is pulling a number for some rows and leaving others blank.. It is not pulling the manufactures name like I thought it was suppose too.

    I have not had any problems with the feeds getting listed though.. All the products show up in google base and the others mentioned just fine..

    Just wondered what the brand column should be showing?

  87. Robert Kent
    #87 | 6th July 2011

    Hi Greg,

    Maybe change it to ->getManufacturers() ? I’ve had a few issues with that too – but it does work quite nicely when it’s done. Just double check that all your products have the manufacturers selected. Also here’s a little trick I noticed the other week – if you can get your manufacturers working and your product title does not contain the manufacturer name – why not concatenate the brand into the product title? Very effective.

  88. Greg
    #88 | 7th July 2011

    Thanks Robert for the fast response!

    I tryed making the getManufactures change noted above but the script just left every row in the column blank.. But it was worth a shot.

    Another question: I have a few free products listed in the catalog at the price of 0.00 . I have to manually save and edit the google_base_feed.txt file and remove the products listed at no cost – If NOT google will NOT accept the feed.

    Is there any function that I can add in the gbase.php script that will exclude the free products from being written in the google_base feed.txt file if they are listed at 0.00 ?

  89. Atom Groom
    #89 | 7th July 2011

    Hey Guys-

    Thanks for putting this together and the community for the continued support.

    I am having troubles with the pricing for my client. I have implemented the price editing mentioned in the comments area, however, google is still spitting out the error:


    Invalid price (316 errors)

    We don’t accept non-numeric values, zero (0), or negative prices. If you are including the currency code or symbol, please make sure it matches the currency of the target country.

    Here’s the feed: http://www.bluecollarsupply.com/export/google_base_feed.txt

    Any help on resolving this would be greatly appreciated!

    Thank you!
    AG

  90. Greg
    #90 | 8th July 2011

    Robert

    I have a few products list in my Magento store with the price of 0.00.. Google was NOT accepting the feed because they do not allow products listed at no cost. I was having to go in and manually edit the google_base_feed.txt file after each run to remove the products listed at a 0 cost..

    I played with the gbase.php file for a while and found out that when I add the below code to the file, the script still functions properly and does not list any product with a 0.00 cost. It now simply skips the free product and writes the file so no manual edit is necessary..

    Just thought I would post this so if anyone else was having the same problem it might help…

    if($product_data['price'] == 0)
    {
    continue;
    }

  91. Greg
    #91 | 8th July 2011

    Robert

    In regard to the script pulling a number in some rows and leaving the others blank; I have been told the number being pulled is the number ID assigned to the Manufacturer when the Manufacturer’s Name is inserted in Magento… The blank rows in the brand column are because the manufacturer(s) listed in the import feed cannot associate the correct manufacturer because they new manufacturer(s) names that/which have to be added to the attributes in Magento..

    So that being said and if it is true: Is there any way for the script to call the manufactures name instead of the manufactures ID number ?

    I’m in the process of adding all the manufacturers in my Magento store, but if I can’t get the script to pull the manufacturer name instead of the manufacturer ID it will not do me much good as far as the brand/manufacturer goes….

    It’s still a great script either way and you have done an excellent job…

  92. Greg
    #92 | 10th July 2011

    Hi Robert

    I fixed the problem of the script (on my site) pulling the Manufacturer ID instead of the Manufacturer Name..

    I replaced this:
    $product_data['brand']=$product->getManufacturer();

    with this:
    $product_data['brand']=$product->getAttributeText(‘manufacturer’);

    The script now loads the correct Manufactures Name in the ‘brand’ column as it should on the google_base_feed.txt file for the products on my site..

    Just thought I’d let you know, so maybe you could pass the information on to anyone else having the same problem as me.

    I now plan to concatenate the brand into the product title as you suggested in an above post..

    Thanks for the GREAT advise..

  93. Greg
    #93 | 11th July 2011

    I got the script to pull the complete category tree by making the changes below:

    I changed this:
    //get the product categories
    foreach(Mage::getResourceSingleton(‘catalog/product’)->getCategoryIds($product) as $_categoryId){
    $category = Mage::getModel(‘catalog/category’)->load($_categoryId);
    $product_data['product_type'].=$category->getName().’, ‘;
    }
    $product_data['product_type']=rtrim($product_data['product_type'],’, ‘);

    To This:
    //get the product categories
    foreach(Mage::getResourceSingleton(‘catalog/product’)->getCategoryIds($product) as $_categoryId){
    $path = ”;
    $parents = explode(‘/’, Mage::getModel(‘catalog/category’)->load($_categoryId)->getPath());
    unset($parents[1]);
    foreach ($parents as $i=>$parent) {
    $parent_name = Mage::getModel(‘catalog/category’)->load($parent)->getName();
    $path = $path . ‘/’ . $parent_name;
    }
    $product_data['product_type'].=substr($path, 2).’, ‘;
    }
    $product_data['product_type']=rtrim($product_data['product_type'],’, ‘);

    Now in the feed under product_type an example is:
    Electronics/Cell Phones/Accessories

    where before the feed was only showing the last category or sub-category ie: Accessories

    It gives me better options to submit the feeds because I have learned that some sites want it one way and some the other..

    Just posted it in case someone wanted the option…

  94. Atom Groom
    #94 | 11th July 2011

    Hey Guys-

    I came to find out this morning that the biggest reason for the rejection of my feed to Google is that this script wraps everything in double quotes.

    As soon as I removed those, the feed was immediately accepted.

    Secondly, the other error was invalid characters, is there a way to remove those dynamically? (stuff like this: ° )

    Thanks,
    AG

  95. Patrick
    #95 | 12th July 2011

    Hi everybody,

    have you read about the changes in the google product feed specifications? See here: http://www.google.com/support/merchants/bin/answer.py?answer=188494

    It seems to me that the whole thing is getting a lot more complicated. For example, no configurable products allowed any more, you need one line for every simple product.

    Rob, will you change your script accordingly?

    Best
    Patrick

  96. Goodjoyce
    #96 | 13th July 2011

    Hello Rob,

    thanks for your script and the useful comments. I was looking for alternative ways to upload the product feed to the GMC, because the old Google-Base-API of my magento 1.4.x shop doesn’t work anymore.

    Do the script fullfill the new requirements as well?

    Thank you very much…

  97. Irene
    #97 | 14th July 2011

    Hi Atom,

    I have the same error. Could you please be more specific about “which part of script you had removed” then the google accept?

    Appreciated!

    Irene

  98. Atom Groom
    #98 | 15th July 2011

    Hi Irene!

    I actually had to do this manually. I used TextEdit on my mac an did a find and replace. So I found ” and replaced with nothing, saved and did a manual upload.

  99. ricky
    #99 | 19th July 2011

    Hi,
    i have solved couple of months ago using change in the script instead of editor. i had have more than 5000 row so it is tough to open in dreamweaver editor though fine in text editor. anyway, just follow the
    $product_data[$k] = ‘”‘.str_replace($bad,$good,$val).’”‘;
    replaced with
    $product_data[$k] = str_replace($bad,$good,$val);

    Also you can removed the garbage code °.

    anyway, if anyone face problem let me know if i can help.

    Thanks

  100. Andrew
    #100 | 3rd August 2011

    Hi,

    I have problem writing to the txt file – just remains blank.

    When I run this (http://www.millhousegifts.com/gbase.php) it refreshes to the homepage (not sure if it is meant to do that) and the txt file remains blank (http://www.millhousegifts.com/google_base_feed.txt)

    Reading an earlier post I moved the files to the root and uploaded an index.php into export folder as a test…

    http://millhousegifts.com/export/index.php
    Creates 404 not found

    http://www.millhousegifts.com/export/index.php
    Goes to homepage

    Any help / advise greatly appreciated.

    Thanks

  101. Robert Kent
    #101 | 3rd August 2011

    Hi Andrew,

    Nice site by the way! I think the problem is your htaccess file – it seems to be rerouting a lot of things to non-www. Normally within an htaccess file for Magento it rewrites everything that is not there to index.php – my guess is that the htaccess file is not picking up on your export folder being there. Please check that they have been uploaded correctly and that your htaccess file has not been tampered with too much. Also are you hosting on an apache server or windows server?

  102. Andrew
    #102 | 3rd August 2011

    Hi Robert,

    Thanks for your quick reply!

    The site is hosted on shared hosting apache – uk2.net

    The htaccess will be untouched by me – he is a link to the contents of it http://millhousegifts.com/HT.txt

    There is a folder I use for eshots that allows me to view a sample index.php but the gbase.php still directs to homepage:

    http://www.millhousegifts.com/eshots/index.php
    http://www.millhousegifts.com/eshots/gbase.php

    That said it only views it with permissions set to ’755′ on ‘eshot’ directory, when I change the permissions on the directory to ’777′ it goes to 404 page not found

    Thanks

    a

  103. Robert Kent
    #103 | 4th August 2011

    Hi Andrew,

    hmmm that seems a little strange to me – have you tried 775 permissions instead? also whats the permissions like on the php files themselves?

  104. Andrew
    #104 | 4th August 2011

    Hi Robert,

    That is it – permissions changed to 755 on all files/folders and it works perfectly for me (777 wasn’t working – may be a shared hosting / uk2 thing?).

    Been a great resource, thank you so much for your help.

    Andrew

  105. ricky
    #105 | 4th August 2011

    Hi Andrew,
    Perhaps this is not permission issue of all the files. you just give 777 in the HT.txt where info will write. i think the problem in the path of php file and txt file. try to test with exit condition after fetch the 5/6 to test rapidly.

    thanks

  106. Christian
    #106 | 25th August 2011

    HI,

    I tried
    $products->addAttributeToFilter(‘status’, 1);//enabled

    to list only simple products but I get:

    Invalid attribute name: ‘type_id’.

    Can anyone help ?

  107. ricky
    #107 | 26th August 2011

    Hi Christian,

    You will get the output to use something like this

    $collection->addAttributeToFilter('status', array('eq' => 1));

    to details please check in the
    http://www.e-commercewebdesign.co.uk/blog/magento-tips/magento-sql-queries-with-addattributetofilter.php
    if anything else let me know.
    Thanks

  108. Bogdan Ciocoiu
    #108 | 13th September 2011

    It’s amazing – the entire post because it actually solves a 24 months bug Magento avoided to solve.

    Because of the total amount of changes (more than 100), do we actually have an updated version of the script that actually works with the latest Google regulations?

    If so, please post the complete code here.

    Thanks,
    Bogdan

  109. marc aurel
    #109 | 24th September 2011

    We have a multistore environment working for our shops and ee use the script with the StoreView Code because it´s more unique and free of entities.

    Mage::app('default'); // or use Mage::app(); for later versions of magento

    Our Website Names contain Entities so they don´t limit the output and we got the whole products of all websites in one shop feed.

    We found a solution to limit the feed to the right store products with just adding addStoreFilter($storeId) to the collection. Here ist the right code

      //---------------------- GET THE PRODUCTS
    $products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId); 

    Just wanted to add this solution here if somebody needs it.

    Thanks to Rob for the whole script!
    marc aurel

  110. James McLaughlin
    #110 | 12th October 2011

    Thank you so much for this script, so much easier than using the new version in 1.6 which isn’t working for us.

    Thanks again.

    Highest Regards,
    James

  111. Sander
    #111 | 10th November 2011

    Hi Guys,

    This is really good, it worked for me. Only needed to change the require_once to my store details. I also added the qty and that is also working.

    Google is saying he is missing MPN and Google category but these are not required. I think if I just create them as attributes and add them like this

    $product_data['sku']=$product->getSku();

    it should work right?

  112. Robert Kent
    #112 | 10th November 2011

    Hi Sander – I recommend you take a look at the updated one: – http://www.e-commercewebdesign.co.uk/blog/magento-tutorials/products-in-google-updated.php that has a few bits in it

  113. Kevin
    #113 | 27th November 2011

    on 1.5.1 you need to add:

    $product->reset();

    right after:

    foreach($prodIds as $productId) {

    or you will get the same category for every product.

  114. Adding Magento products to Google Base / Magento Support Team Blog
    #114 | 30th November 2011

    [...] If you still can’t get your head arround this, CreareGroup has provided an alternate way to submitt your Magento products to the Google Base. [...]

Post A Comment

Your comments:
Enclose code snippets within the appropriate tags: [php][/php]   [js][/js]   [xml][/xml]   [css][/css]   [html][/html]
E.g: [php]<?php echo "hello world"; ?>[/php]

Search Blog

Archives

For the record...

Views & opinions in this blog are those of the individual and do not necessarily reflect those of E-commerce Web Design or the Creare Group.