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)

cloud9 08-05-2003 07:46 PM

find:

Code:

$image_url = $http_location.'/image.php?productid='.$products[$key][productid];

replace with:

Code:

$image_url = '';
if ($products[$key][image_x] <> 0)
{
    $image_url = $http_location.'/image.php?productid='.$products[$key][productid];
}


jgkiefer 08-07-2003 07:17 PM

Quote:

Originally Posted by cloud9
find:
Code:

$image_url = $http_location.'/image.php?productid='.$products[$key[productid];
replace with:
Code:

$image_url = '';
if ($products[$key][image_x] <> 0)
{
    $image_url = $http_location.'/image.php?productid='.$products[$key][productid];
}



That worked great! Now I have a really tough question.

I have a category that I just use for custom orders called "Custom Orders". Under this category I am able to create subcategories that are assigned membership levels so each custom account has its own subdirectory. The only problem with this is that the froogle mod prints all the directories regardless of membership levels.

Question-
How can I set the Froogle mod to not print a designated category and subcategories? I do not want to list the Custom Orders category and subcategory products with Froogle. I could take them out by hand but it seems that there is an easy way to do this using conditional statements?

successful 08-07-2003 09:06 PM

I never got Froogle to work until I installed marketing manager. See my post at http://forum.x-cart.com/viewtopic.php?t=5245 .

jgkiefer 08-07-2003 10:03 PM

Quote:

Originally Posted by successful
I never got Froogle to work until I installed marketing manager. See my post at http://forum.x-cart.com/viewtopic.php?t=5245 .


The Froogle mod that HairGuy put togeather works great, I just want to know how to restrict a directory.

davesphoto 08-08-2003 06:42 AM

This froogle_update sounds great, but every time i try to copy the code I get the error:

Quote:

Parse error: parse error, unexpected T_STRING in /www/d/davesphoto/htdocs/store/provider/froogle_update.php on line 48


I have the required variables set in my config.php, and I dont really see what is wrong.

Help!

Thanks,
Chad
www.davesphotoemporium.com

HairGuy 08-14-2003 09:05 PM

Try changing line 48 from
Code:

if ($_SERVER[DOCUMENT_ROOT]) {
to
Code:

if ($_SERVER['DOCUMENT_ROOT']) {
and see if it fixes the problem.

HairGuy 08-14-2003 09:18 PM

How to restrict a category
 
In response to jgkeifer:

If you want to skip a certain category, just add a bit more logic.

For example, change this:
Code:


if ($products[$key][forsale] == 'N' ||  # skip products not available for sale
    $products[$key][price] <= 0.00) {  # skip products with zero price
    continue;
}

to
Code:

if ($products[$key][forsale] == 'N' ||  # skip products not available for sale
    $products[$key][price] <= 0.00 ||  # skip products with zero
price
    $category == 'Whatever category you want to skip') {
    continue;
}


123computerbooks 08-21-2003 05:34 AM

I cant get my param00 , the isbn for the book to write in the output file any suggestions?




Code:

<?
#
# $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;

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";
}

  # $fp = tmpfile();

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

$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 = "xxxxxx";  # 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)");

 
  #
  #  Set up Froogle header
  #
  $product_url = 'product_url';
  $name        = 'name';
  $description = 'description';
  $price      = 'price';
  $image_url  = 'image_url';
  $category    = 'category';
  $offer_id    = 'offer_id';
  $isbn        = 'isbn';

  fwrite($fp, $product_url.$tab.
            $name.$tab.
            $description.$tab.
            $price.$tab.
            $image_url.$tab.
            $category.$tab.
            $offer_id."\n").
            $isbn.$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
        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];

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

  rewind($fp);

 
  #
  #  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;
      };
  }
  fclose($fp);
}

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

?>


123computerbooks 08-21-2003 09:02 AM

I am using 3.4.4 i did some editing i need to see what the thumbnail variable is so far i have

Code:

$image_url = $products[$key][tmbn_url]
and its not writing th e thumb url path

firecompanies 12-02-2003 09:35 PM

Re: It has been running in production for the past month
 
Quote:

Originally Posted by HairGuy
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:
Code:

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.


The froogle_update.php works GREAT from the browser. But, unfortunately when I try to initiate it from the command line, I get the following error:

Code:


Fatal error:  Call to undefined function:  mysql_connect() in /home/web/store/include/func.php on line 41


Any ideas?

Craig Elliott
FireCompanies.com


All times are GMT -8. The time now is 03:02 AM.

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