X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Froogle Google (https://forum.x-cart.com/showthread.php?t=2286)

jeeya 07-22-2003 04:13 PM

I have filled up form and now they said that they will send information to upload database.

jeeya 07-23-2003 02:41 PM

ok, I sent them data feed and they want me to delete lines, now I don't know what lines! I open my data in exel and saw blank lines between products - Are they Talking about those lines? OR I have some lines blank for shipping charges where I had not put any values are they one?

Please let me know the quick way to delete them lines.

davesphoto 07-25-2003 09:49 AM

I think I got it!
This does not print any extra lines. It also removes any extra tabs created by multiple carrage returns in the description (I am not sure why this happened with the old code but another |strip did the trick). Anyways, this is what I am using now for product_export.tpl:


{section name=prod_num loop=$products}
{$products[prod_num].descr|replace:"\r":" "|replace:"\n":" "|replace:"\t":" "|replace:"\"":""|replace:",":","|strip_tags |strip}{$delimiter}
{$products[prod_num].category|replace:"/":" > "|replace:"\"":""}{$delimiter}

Now be carefull! This tpl seems very sensitive to extra spaces or lines in the code, so don't leave any! Also notice I am using the short description, not the full one (I dont use it for display on the website so now it is the "froogle" description).

Also please note: You must define and assign the variable $line as the line delimiter in the export.php.

Put this at the top:

$line = "\n";

And this right after $smarty->assign("delimiter", $delimiter);:

$smarty->assign("line", $line);

This should export data ready for upload to froogle without modification (at least it does for me :wink: ).

I am not a programmer and do not know all the etiquette so I hope I am not stepping on any toes posting this code seeing as how some of the lines are unchanged from the code posted earlier in the discussion. The idea is quite different though. Anyway, I make no claim to the code; use it for anything you want! Hopefully it helps!

HairGuy 07-26-2003 11:35 AM

Automatic Froogle Update Code - No Templates Needed!
Here's some code that will automatically create a product file and send it to Froogle.

You can call it from X-Cart or it can be run automatically from 'cron' (on a Unix/Linux system).

I suggest you install it in the xcart/provider directory.



# $Id: froogle_update.php,v 1.6 2003/05/25 15:09:08 lfhair Exp $
# froogle_update.php
# This module will automatically export your products and send
# (using FTP) a properly-formatted file to Froogle.
# It can be run from X-Cart or it can also be run from the command
# line.  Running it from the command line is useful for setting
# up a 'cron' job that will automatically update your Froogle listings
# periodically (like once a week or once a day).  For example,
# the following crontab entry would update Froogle every Saturday
# at 2:00am:
#  0 2 * * 6 /usr/bin/php -q /home/mydir/www/xcart/provider/froogle_update.php
# In order for things to work, you must define the following variables in
# your config.php file:
#    $froogle_username = 'myfroogle';
#    $froogle_password = 'mypass';
# Values for the above are assigned by Google when you sign up for their
# Froogle service (see froogle.google.com for more info).
# The following variables are optional:
#    $froogle_host    - defaults to 'hedwig.google.com'
#    $froogle_partner  - set this if you want to track Froogle hits as
#                        an affiliate (i.e. set $froogle_partner="froogle")
#    $froogle_filename - name of the file that will be sent to Froogle
# Copyright 2003 by Jeff Groves (jeff@lfhair.com - www.lfhair.com)
# You have permission to use this code as long as you include the
# header lines above.  There are no guarantees that this code will
# work as expected.
require "../smarty.php";
require "../config.php";

$command_line_mode = false;

        #  Running from the web, make sure we authenticate the user
        require "./auth.php";
        require "../include/security.php";
        $BR = '
} else {
        #  Running from command line
        $command_line_mode = true;
        ini_set('html_errors', '0');
        $BR = "\n";

$tab = "\t";
$partner_track = "";

# Use this condition when single mode is disabled

$provider_condition = ($single_mode ? "" : "and $sql_tbl[products].provider='$login'");

if (! $froogle_host) {
        $froogle_host = "hedwig.google.com";  # default Froogle host

if (! $froogle_username) {
        echo "ERROR: \$froogle_username is not set, it should be defined in your 'config.php' file.".$BR;

if (! $froogle_password) {
        echo "ERROR: \$froogle_password is not set, it should be defined in your 'config.php' file.".$BR;

if ($froogle_partner) {
        # if set, track froogle hits as an affiliate

if (! $froogle_filename) {
        $froogle_filename = $froogle_username.'.txt';  # default Froogle filename

if ($froogle_username && $froogle_password) {
        echo "Exporting products".$BR;
        $products = func_search_products("1 $provider_condition group by $sql_tbl[products].productid order by $sql_tbl[products].productid", $user_account['membership']);

if ($products) {
        # These patterns will remove HTML tags, javascript sections
        # and white space. It will also convert some
        # common HTML entities to their text equivalent.
        $search = array (
                "'<script[^>]*?>.*?</script>'si",  // Strip out javascript
                "'<[\/\!]*?[^<>]*?>'si",          // Strip out html tags
                "'[\s]+'",                // Strip out white space
                "'&(quot|#34);'i",                // Replace html entities
                "'&#(\d+);'e");                    // evaluate as php

        $replace = array (
                " ",
                " ",

        $fp = tmpfile();
        #  Set up Froogle header
        $product_url = 'product_url';
        $name        = 'name';
        $description = 'description';
        $price      = 'price';
        $image_url  = 'image_url';
        $category    = 'category';
        $offer_id    = 'offer_id';

        fwrite($fp, $product_url.$tab.

        #  Build an export file
        $count = 0;
        foreach ($products as $key => $value) {
                if ($products[$key][forsale] == 'N' ||  # skip products not available for sale
                    $products[$key][price] <= 0.00) {  # skip products with zero price

                $product_url = $http_location.'/customer/product.php?productid='.$products[$key][productid].$partner_track;
                $name = preg_replace($search, $replace, strip_tags($products[$key][product]));
                $description = preg_replace($search, $replace, strip_tags($products[$key][fulldescr]));

                # if fulldescr is blank, use short description
                if ($description == "") {
                        $description = preg_replace($search, $replace, strip_tags($products[$key][descr]));
                $price = $products[$key][price];
                $image_url = $http_location.'/image.php?productid='.$products[$key][productid];

                # convert '/' to '>' in category
                $category = eregi_replace('/', '>', $products[$key][category]);
                $offer_id = $products[$key][productcode]; # jjj - use productid ???
                fwrite($fp, $product_url.$tab.


        #  Connect to Froogle and send file via FTP
        $conn_id = ftp_connect($froogle_host);
        $login_result = ftp_login($conn_id, $froogle_username, $froogle_password);

        if ((!$conn_id) || (!$login_result)) {
                echo "FTP connection failed!".$BR;
                echo "User '$froogle_username' unable to connect to $froogle_host".$BR;
        } else {
                echo "User '$froogle_username' connected to $froogle_host".$BR;
                echo "Beginning FTP transfer of $count products".$BR;
                if (ftp_fput($conn_id, $froogle_filename, $fp, FTP_ASCII)) {
                        echo "OK - Transfer of file '$froogle_filename' was successful".$BR;
                } else {
                        echo "ERROR - Unable to transfer file '$froogle_filename'".$BR;

if (! $command_line_mode) {
        echo '
Return to previous page';



jeeya 07-27-2003 02:52 PM


So How do I upload that Code??

And After that Will it send product data feeds byself or I will have to use ftp and upload it on froogle's server??

And If it sends automatically, How Do I know it has been sent? Also, Where do I put my User Name and Password for Froogle?


jpsowin 07-27-2003 06:36 PM

Did you read the instructions? It's all right there for you ;)

BTW, this looks like a very good mod. I haven't tried it myself, but it looks pretty solid from looking at the code. Great work!

HairGuy 07-28-2003 06:09 PM

It has been running in production for the past month
I've been running the above code on my production system for over a month and it works fine. I have it set up in 'cron' to also email me a message when it runs. You can do something like this in your crontab:

15 2 * * * /usr/bin/php -q $HOME/public_html/xcart/provider/froogle_update.php | mail -s 'Froogle Update' me@mydomain.com
Sorry, but I don't have time to explain the basics of crontab and PHP coding to newbies. However, if you want to pay my normal consulting fees, I'll be happy to set things up for you.

cloud9 07-28-2003 06:44 PM

For anybody using Froogle, can you comment on how much traffic you are getting from getting listed there? Thanks...

kpayne 07-28-2003 06:54 PM

Cloud9, you can install X-Affiliate and assign froogle a partner id and track it that way.

Or, you can use your own tracking system. I have all froogle links pointing to "/froogle/?id=$productid" and I wrote my own tracking and redirection code. There's tons of code out there if you want to use that solution -- just check hostscripts or resourceindex.

Hope this helps!

cloud9 07-28-2003 07:38 PM

Thanks Kurt, but I don't anticipate a problem tracking my stats once I'm in Froogle, I was just wondering what kind of hits stores that are already in Froogle were getting?

HairGuy, thanks so much for that script it made this process a breeze!

For those that want to actually see what is being generated, you can modify the php above like this...

# $fp = tmpfile();

$fp = fopen("./froogle_temp.txt", "w+");

All times are GMT -8. The time now is 11:10 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.