Magento Forum

   
Export Module for Google Base
 
hyteckit
Sr. Member
 
Avatar
Total Posts:  166
Joined:  2008-04-01
Los Angeles, CA
 
turbo1 - 13 September 2008 01:17 PM

LOL  point taken. I do truly believe that if you know how to do something & are taking advantage of other people’s free help, you should also contribute for free to the community. I believe in freedom of information.  I’m actually in the process of hiring a developer to write a Google Base PHP script for me, and I will post it for free. Why? Because that’s the right thing to do.. because it will help others.. because I would be an ass to keep it secret for myself.  grin

Cool.  Cause I was going to take time out of my busy schedule to finish up the GoogleBase module, but now it looks like I don’t have to.
Now I can go back to working on my order manager/fulfillment system.

I can’t wait for your contribution.

 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

@fifthave - No worries, part of my terms are that I own rights to the code once payment is made. And I will most definitely post it when it’s done, with no strings attached cool smile

@hyteckit - Too little, too late (and I don’t believe you) hmmm .

/me will be back as soon as I have a working script smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
edge
Jr. Member
 
Total Posts:  13
Joined:  2007-12-04
Hemel Hempstead, Newcastle-Upon-Tyne, England
 

For anyone having trouble with db’s script in the latest versions of Magento, see if this works for you:

<?php
    
require_once 'app/Mage.php';
        
umask(0);
        
Mage::app('default');
        
        
/**** CONFIGURATION ****/
        
$media_path "media/catalog/product";
        
/***********************/
        
        
function addQuotes($text{
            
return('"'.$text.'"');
        
}
        
function cleanForCSV($text{
            $text 
str_replace('"'""$text);
            
$text str_replace("\r\n"" "$text);
            
$text str_replace("\t"""$text);
            return 
$text;
        
}
        
        $products 
Mage::getModel('catalog/product')->getCollection();
        
$products->addAttributeToFilter('status'1);
        
$products->addAttributeToFilter('visibility'4);
        
$products->addAttributeToSelect('*');
        
$products->load();
        
        
$fields = array('id','title','description','link','image_link','price');
        echo 
implode("\t"$fields)."\r\n";
        
        foreach(
$products as $_product{
            $data 
$_product->getData();

            
$csv = array($data['sku'],
                                     
$data['name'],
                                     
$data['description'],
                                     
$_product->getProductUrl(),
                                     
Mage::helper('catalog/image')->init($_product'image'),
                                     
$data['price']);
            
$csv array_map("cleanForCSV"$csv);
            
$csv array_map("addQuotes"$csv);
            
            echo 
implode("\t"$csv)."\r\n";
        
}
?>

Also, the $domain variable is no longer necessary, since the script now uses the Mage object to generate an absolute URL for both the product URL and the image URL.

Thanks for doing 99% of the work on this, db.

 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

@edge
Thank you for posting this. It seems to work somewhat for me (version 1.1.4).

I should have my script ready to post soon - I’ve hired someone and their estimated completion time is 1 week as they’re doing other projects too. So hopefully between Edge’s script and my script, everyone will have a working Base export LOL

 
Magento Community Magento Community
Magento Community
Magento Community
 
xgabo
Member
 
Total Posts:  40
Joined:  2008-09-11
 

This did not work for me, this code and the code at the bigging of this forum did not create links with sub categories, so if the product is at yoursite/garmin/gps/product.html the google feed just does yoursite/product.html (actually anything not on the front page should look like this mysite/index.php/catalog/product/view/id/88/s/samle-product/category/19/)

with the code below I get http://www.mysite.com/googlefeed.php/sampleproduct.html any ideas?

edge - 14 September 2008 07:33 PM

For anyone having trouble with db’s script in the latest versions of Magento, see if this works for you:

<?php
    
require_once 'app/Mage.php';
        
umask(0);
        
Mage::app('default');
        
        
/**** CONFIGURATION ****/
        
$media_path "media/catalog/product";
        
/***********************/
        
        
function addQuotes($text{
            
return('"'.$text.'"');
        
}
        
function cleanForCSV($text{
            $text 
str_replace('"'""$text);
            
$text str_replace("\r\n"" "$text);
            
$text str_replace("\t"""$text);
            return 
$text;
        
}
        
        $products 
Mage::getModel('catalog/product')->getCollection();
        
$products->addAttributeToFilter('status'1);
        
$products->addAttributeToFilter('visibility'4);
        
$products->addAttributeToSelect('*');
        
$products->load();
        
        
$fields = array('id','title','description','link','image_link','price');
        echo 
implode("\t"$fields)."\r\n";
        
        foreach(
$products as $_product{
            $data 
$_product->getData();

            
$csv = array($data['sku'],
                                     
$data['name'],
                                     
$data['description'],
                                     
$_product->getProductUrl(),
                                     
Mage::helper('catalog/image')->init($_product'image'),
                                     
$data['price']);
            
$csv array_map("cleanForCSV"$csv);
            
$csv array_map("addQuotes"$csv);
            
            echo 
implode("\t"$csv)."\r\n";
        
}
?>

Also, the $domain variable is no longer necessary, since the script now uses the Mage object to generate an absolute URL for both the product URL and the image URL.

Thanks for doing 99% of the work on this, db.

 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

We’re almost there.. hang in a little longer.  cheese

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lenny2
Sr. Member
 
Total Posts:  171
Joined:  2008-05-21
München
 

Go go go ... wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dunc
Member
 
Avatar
Total Posts:  56
Joined:  2008-08-05
 
turbo1 - 22 September 2008 05:34 AM

We’re almost there.. hang in a little longer.  cheese

Glad to hear that, for some reason since the 16th September my datafeed has not been working, I’ve been getting an error from Google Base stating “We’re having trouble reaching your site.” but it works fine through a browser or opening the address in Excel. I contacted Google and they say they do not support php but I’ve asked them to explain how it was working before. As usual with Google, a long delay between communication so 2 emails have been achieved in the last few days and nothing resolved yet.

As you can see from the following link, the feed is working fine… http://www.electricshowersdirect.com/data_feed.php

I’ll look forward to an alternative though.

 
Magento Community Magento Community
Magento Community
Magento Community
 
xgabo
Member
 
Total Posts:  40
Joined:  2008-09-11
 

The feed seemed to work ok for those who had all there products posted in the main category.  The feed did not work for products in sub categories.  The issue is that in the code, it lets you specify the base url and then it adds the product.html on the end.  when you have more that one category, you cant insert the base url + category for all items.  I hope this gets figured out.  Varien should really work this into its code and not make us have to edit it ourselves.  Other open source programs like oscommerce, zencart, and virtuecart, all have this feature with an easy to use import/ export program.  I do think that magneto has a stronger back bone than these other programs, its just lacking some very essential features for an ecommerce solution.

 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

@Dunc
It looks like it’s spitting out your data to PHP instead of a TXT file. We used something similar with osCommerce, you’d manually run a PHP file and it would generate a TXT file. you’d then tell Google the location of that TXT file and all was well smile

I had hoped to have something to post by today, but alas there are delays cool smirk  because of my lack of explaining to the developer exactly what I was looking for.  We’re working through it LOL

 
Magento Community Magento Community
Magento Community
Magento Community
 
xgabo
Member
 
Total Posts:  40
Joined:  2008-09-11
 

If you could find a way to download the product id, this code works for all ids-

http://www.yoursite.com/data/index.php/catalog/product/view/id/1/

I went into php my admin and looked in the url rewrite files but Itd doesn’t give a straight froward product id from what I saw.

 
Magento Community Magento Community
Magento Community
Magento Community
 
misterMan
Member
 
Total Posts:  57
Joined:  2008-07-15
 

Hey this looks great! Please keep us informed.

 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

The script is done smile We are finalizing payment and wrapping up. I will return shortly grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

As promised… (notes to follow in second post)
run this at your own risk! Please test it on a non-production server, I’m not responsible for unique setups that may not like this script.

EDIT - some code got cut off, plz download the file attached in a later post smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

Full credit goes to ANDA for the hard work to get this script done.

Please, PLEASE consider doing the same thing I did if you have the funds to do so. It benefits everyone.

Notes on the script - create an “export” folder in your root directory. Drop the lines of code above into a PHP file and run it on your server. It work son my setup, but remember that you run this at your own risk. It works 100% for me, 5000 products, with no issues. If it kills your server, you’ve been warned!

tongue wink

And, by all means, modify and improve on it as you see fit. It benefits everyone smile Just give credit where credit is due (Anda).

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top