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 Export Mod for 3.5.2 ?? (https://forum.x-cart.com/showthread.php?t=5933)

Taekwondo 01-09-2004 10:30 AM

Froogle Export Mod for 3.5.2 ??
 
Does anyone have a final mod that will work in 3.5.2 ?
I read the huge thread but looks like a lot of back and forth fixes going on.

TW

finestshops 01-09-2004 01:11 PM

Re: Froogle Export Mod for 3.5.2 ??
 
Quote:

Originally Posted by Taekwondo
Does anyone have a final mod that will work in 3.5.2 ?
I read the huge thread but looks like a lot of back and forth fixes going on.
TW


Below is slightly modified version of the great mod by HairGuy
(http://forum.x-cart.com/viewtopic.php?t=2940&postdays=0&postorder=asc&high light=froogle&start=15)

It saves urls to full product images (not small tumbnails) and it works fine in several 3.5.2 stores triggered by cron jobs or from control panel.

create new file, paste code below and upload it to xcart/admin directory

xcart/admin/froogle_update.php

Code:

<?
#
# $Id: froogle_update.php,v 1.6 2003/05/25 15:09:08 lfhair Exp $
#
# froogle_update_cron.php
#
# 15 2 * * * /usr/bin/php -q $HOME/public_html/xcart/provider/froogle_update.php | mail -s 'Froogle Update' me@mydomain.com
#
# 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:
#
#    $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
#
# uncomment 2 lines below are for 3.4.? version
#
# require "../smarty.php";
# require "../config.php";
#
# comment next line for 3.4.? version

require "./auth.php";

# Values for the above are assigned by Google when you sign up for their
# Froogle service (see froogle.google.com for more info).

    $froogle_username = "XXXXX";
    $froogle_password = "XXXXX";
    $froogle_partner  = "froogle";

#
# The following variables are optional:
#
#    $froogle_host    = " ";

$command_line_mode = false;

if ($_SERVER[DOCUMENT_ROOT]) {
  #
  #  Running from the web, make sure we authenticate the user
  #
#  require "./auth.php";
#  require "../include/security.php";
  set_time_limit(1800);
  $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
  $partner_track="&partner=$froogle_partner";
}

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
      "'&(amp|#38);'i",
      "'&(lt|#60);'i",
      "'&(gt|#62);'i",
      "'&(nbsp|#160);'i",
      "'&(iexcl|#161);'i",
      "'&(cent|#162);'i",
      "'&(pound|#163);'i",
      "'&(copy|#169);'i",
      "'&(lsquo|#8216);'i",
      "'&(rsquo|#8217);'i",
      "'&(ldquo|#8220);'i",
      "'&(rdquo|#8221);'i",
      "'&#(\d+);'e");                    // evaluate as php

  $replace = array (
      "",
      "",
      " ",
      "\"",
      "&",
      "<",
      ">",
      " ",
      chr(161),
      chr(162),
      chr(163),
      chr(169),
      "'",
      "'",
      '"',
      '"',
      "chr(\\1)");

  $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, "# html_escaped = YES\n".
                $product_url.$tab.
            $name.$tab.
            $description.$tab.
            $price.$tab.
            $image_url.$tab.
            $category.$tab.
            $offer_id.$tab.
                "instock\n");

  #
  #  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
        continue;
      }
      $count++;

      $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];

$sql_query = "select * from $sql_tbl[images] where productid='".$products[$key][productid]."' limit 1";
$images = func_query($sql_query);
        if (is_array($images)) {
                foreach($images as $k=>$v)
                        if (eregi("^(http|ftp)://", $v["image_path"])) {
                        # image_path is an URL
                                $images[$k]["tmbn_url"] = $v["image_path"];
$image_url = $images[$k]["tmbn_url"]; }
                        elseif (eregi($xcart_dir, $v["image_path"])) {
                    # image_path is an locally placed image
                                $images[$k]["tmbn_url"] = $http_location.ereg_replace($xcart_dir, "", $v["image_path"]);
$image_url = $images[$k]["tmbn_url"];
                        }
        }


      # convert '/' to ' > ' in category
      $category = eregi_replace('/', '>', $products[$key][category]);
      $offer_id = $products[$key][productcode]; # jjj - use productid ???
      fwrite($fp, $product_url.$tab.
                  $name.$tab.
#                  "\"".$description."\"".$tab.
                  $description.$tab.
                  $price.$tab.
                  $image_url.$tab.
                  $category.$tab.
                  $offer_id.$tab."Y\n");
  }

  rewind($fp);

  #
  #  Connect to Froogle and send file via FTP
  #
  $conn_id = ftp_connect($froogle_host) or die("Couldn't connect to $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;
      };
  }
  fclose($fp);
}

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

?>


Quote:

how do I do run it within X-cart ?

in skin1/admin/menu_admin.tpl just change

Code:

{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title="Administration" menu_content=$smarty.capture.menu }


to

Code:



Froogle Update

{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title="Administration" menu_content=$smarty.capture.menu }


:wink:

DataViking 01-09-2004 04:28 PM

Thank you I will try this

finestshops 01-10-2004 07:13 AM

Quote:

Originally Posted by Taekwondo
I get the following error when I run the script:

Fatal error: Call to undefined function: ftp_connect()


You have to ask your host to install ftp module for php (enable ftp support) for your account.

Taekwondo 01-10-2004 07:17 AM

Thanks
 
Thanks again.

jmell 01-15-2004 08:44 PM

I did the mod on my site and all worked well.
Thanks for the mod :D

Courage 01-18-2004 09:05 AM

@27stars

1. Can you make this export the file into my browser ?

2. On your version, i still need to add in config.php

$froogle_username = "xxxxx";
$froogle_passwor = "xxxxxx";

?

finestshops 01-18-2004 02:33 PM

Quote:

Originally Posted by Courage
@27stars
1. Can you make this export the file into my browser ?


Change user, pass and ftp server variable to your ftp login info,
the script will save file on your server.

Quote:

Originally Posted by Courage
2. On your version, i still need to add in config.php

$froogle_username = "xxxxx";
$froogle_passwor = "xxxxxx";

?


No, you do not have to add anything to config.

Taekwondo 01-18-2004 04:10 PM

Can't to find template engine!
 
27stars,

I get this error when I try this.

"Can't to find template engine!"

I saw that many others get this error.
Im running V3.5.2

TKD

finestshops 01-18-2004 05:57 PM

Re: Can't to find template engine!
 
Quote:

Originally Posted by Taekwondo
I get this error when I try this.
"Can't to find template engine!"
I saw that many others get this error.
Im running V3.5.2
TKD


Did you make any changes? because this is exactly what i use on several 3.5 installations. You only have to make change if it's on for 3.4

Taekwondo 01-19-2004 04:30 AM

27Stars
 
I did make some changes, but have just tried reverting back to the original code you posted, and I get this error:

Fatal error: Call to undefined function: ftp_connect() in /usr/local/psa/home/vhosts/taekwondogear.net/httpdocs/xcart/admin/froogle_update_cron.php on line 232

Which I believe means that FTP for php is not enabled on my server.

What I need is a way to save the export to file, instead of using the ftp_connect() function. Then I can FTP it to Froogle myself. I would be happy with that.

Thanks,
TKD

CSParker1 01-23-2004 07:21 AM

Great Mod
 
We greatly appreciate the contribution

finestshops 01-23-2004 08:56 AM

Re: 27Stars
 
Quote:

Originally Posted by Taekwondo
Fatal error: Call to undefined function: ftp_connect() Which I believe means that FTP for php is not enabled on my server.


Correct

Quote:

Originally Posted by Taekwondo
What I need is a way to save the export to file, instead of using the ftp_connect() function. Then I can FTP it to Froogle myself. I would be happy with that.


You can ask your host to install ftp support for php which they usually do not have any problem with and, if you need the file itself, change froogle ftp account info to your own ftp account info. File will be saved in your account and you can just download it. Or maybe somebody knows an easy way to change ftp_connect($froogle_host) to saving file on your computer.

The easiest way is getting Froogle add-on from firetank, which will save froogle data feed file on your computer.

curpier 01-23-2004 08:57 AM

Finally got it working. Thanks again for the contribution :D

vtfox 01-25-2004 06:18 AM

I looks like I'm getting the ftp connection, but I am getting the following error (the xxxxxxx's have been put in to protect the innocent):

Code:

Exporting products
User 'xxxxxxx' connected to hedwig.google.com
Beginning FTP transfer of 412 products

Warning: ftp_fput(): bind() failed: Permission denied (13) in /home/xxxxxxx/www/www/xcart/admin/froogle_update.php on line 241

Warning: ftp_fput(): User xxxxxxx logged in. Access restrictions apply. in /home/xxxxxxx/www/www/xcart/admin/froogle_update.php on line 241
ERROR - Unable to transfer file 'xxxxxxx.txt'


Any ideas?

Taekwondo 01-25-2004 06:23 AM

27stars ..

Thanks for all your help. My host installed FTP for PHP and all is well.


vtfox ...

Make sure you have the user name and password variables in your config.php. Verify that you can ftp directly and upload a file using the user name and passowrd provided by Froogle.

finestshops 01-25-2004 07:05 AM

Quote:

Originally Posted by vtfox
I looks like I'm getting the ftp connection, but I am getting the following error (the xxxxxxx's have been put in to protect the innocent):

Any ideas?


Check if you are using correct froogle login (not your own ftp login). Try to login to froogle with your information via standard ftp application (WS_FTP for example). Most likely something is wrong with your froogle account.

Please note: you will not be able to submit another file until froogle processed the file you already submitted. Sometimes it takes 1-2 days to be able to submit file again.

vtfox 01-25-2004 07:31 AM

I have entered my username and password into my config.php file and I have confirmed that they work using SmartFTP, but I'm still getting this error:
Code:

Warning: ftp_login(): Login incorrect. in /home/xxxxxxx/www/www/xcart/admin/froogle_update.php on line 233
FTP connection failed!
User ' ' unable to connect to hedwig.google.com


Is there something I'm still missing?

Thanks for all your help!

finestshops 01-25-2004 07:40 AM

Quote:

Originally Posted by vtfox
I have entered my username and password into my config.php file and I have confirmed that they work using SmartFTP, but I'm still getting this error:
Is there something I'm still missing?


This script is not using username and password in config. username and password should be entered directly into the script.

see under

Code:

require "./auth.php";
[/code]

AKR 08-14-2004 11:01 PM

in the errors section in froogle merchant center, it told me "Obsolete configuration header." does anyone else get this or know how to fix it?

edit: to elaborate, here is a qoute from froogle: "Your feed contained a parameter, such as '# quoted=YES', which we no longer support. Please remove any extra headers (which begin with a # sign) from your feed. The first line in your feed should contain the names of the fields you are using. To ensure that your feed is being processed correctly without these parameters, please verify the settings for that feed file entry."

so, do i just take out all of the comments and i'm good?

mream 10-14-2004 07:05 PM

I have a couple questions about the hairguy Froogle mod. I installed it and it seems to run ok. I changed the ftp info to put it on my server so I can see what it looks like. I can't find the file, though, so I don't know that it's actually run.

Also, after running it, the message says I only exported 1 item. Any ideas on what I can look at?

Thanks,

jake61 04-06-2005 11:05 AM

I get this error when running...

Quote:

Exporting products Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 41 bytes) in /var/www/html/store/include/func.php on line 86


Any ideas ???

Thanks,

finestshops 04-06-2005 11:09 AM

Quote:

Originally Posted by jake61
I get this error when running...
Quote:

Exporting products Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 41 bytes) in /var/www/html/store/include/func.php on line 86
Any ideas ???
Thanks,


You have to contact your host and ask to make an adjustment.
If they will not be able to do this - change the host :wink:

jake61 04-08-2005 12:51 PM

Thanks. I contacted my host and they want to know the maximum file size I am trying to upload through php?

I downloaded my sql database and it is 847MB (I have nearly 10,000 items in the store). I have no idea what to tell them about file size. I would guess the froogle file shouldn't be too large, since it just contains links and titles.

Any idea what I should tell my host?

Thanks again,

jake61 04-09-2005 12:11 PM

OK got it to run, but with another error:

Quote:

Warning: ftp_fput(): Can't build data connection: Connection refused. in /var/www/html/store/admin/froogle_update.php on line 240 ERROR - Unable to transfer file

The error on Froogle site says "Blank feed"

Thanks,


All times are GMT -8. The time now is 04:31 AM.

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