Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Anyone come up with a solution for us that use Froogle datafeeds?


Guest

Recommended Posts

I'm speaking of the Froogle feeder contribution. Worked fabulously; until Google decided to abandon Froogle recently.

 

The obvious happens; cannot connect to the server. The uploads generated by the contribution no longer go to Froogle; they need to go to Googlebase. I've tried changing the location the file should be uploaded to with no luck.

 

I can still generate the file and upload it to Googlebase manually, but...I'm getting errors on 100 out of 900 items, and I have no idea what's causing the errors.

 

I've searched thru the Froogle data feed contribution thread and see nothing.

 

Anyone know if there's some simple fix to my froogle.php file I can make to send those files to Googlebase now, rather than Froogle?

Link to comment
Share on other sites

I have a modified version of the froogle.php file that I've been using for google base. I've been using it for months, long before they made the changes, but it still works! Just used it tonight to upload to google base.

 

As I recall, I had to specify a separate username and password for google base - separate from my Froogle name/password. So that might be something you need to do.

 

The file is some form of Froogle Data Feeder 1.62

 

The top of the file has this info:

 

// Title: Froogle Data Feeder 1.62

// Author: Calvin K

// Contact: [email protected]

// Organization: Conceptual Networking

// Last Update: 12/21/05

 

If that is something like what you are using, then this replacement should work, once you fill in the necessary parameters.

 

The credit goes to whoever wrote this...I didn't have to change much (if anything). Like I said I can't remember. I'll put up another post w/ the code. It's loooong. I took out all of my details...from the parameters going from the beginning to about line 75. Just fill in your info.

Link to comment
Share on other sites

<?php
//  Title: Froogle Data Feeder 1.62
//  Author: Calvin K
//  Contact: [email protected]
//  Organization: Conceptual Networking
//  Last Update: 12/21/05

//
// This feeder has been revised to work with Ultimate SEO URLs 2.1d (http://www.oscommerce.com/community/contributions,2823)
//


// Change to 'false' to disable the use of SEO
define('SEO_ENABLED','false');

if(SEO_ENABLED=='true'){
 //********************
 // Modification for SEO
 // Since the ultimate SEO was only installed on the public side, we will include our files from there.
 require_once('../includes/configure.php');
 require_once('../includes/filenames.php');
 require_once('../includes/database_tables.php');
 $languages_id = 1;   // CHANGEME - Change this to the id of your language.  BY default 1 is english


 include_once('../' .DIR_WS_CLASSES . 'seo.class.php');
 $seo_urls = new SEO_URL($languages_id);

 function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
 global $seo_urls;
 return $seo_urls->href_link($page, $parameters, $connection, $add_session_id);
 }
}

//********************

//  Start TIMER
//  -----------
$stimer = explode( ' ', microtime() );
$stimer = $stimer[1] + $stimer[0];
//  -----------


$OutFile = "full_path_to_your_google_base_file"; //"CHANGEME-full-path-to-file-with-777-dir-and-file-permissions.fr-outfile.txt";
$destination_file = "your_file";  //"CHANGEME-filename-to-upload-to-google_base.txt";
$source_file = $OutFile;
$imageURL = 'path_to_your_image_directory';
if(SEO_ENABLED=='true'){
  $productURL = 'product_info.php';   // ***** Revised for SEO
$productParam = "products_id=";   // ***** Added for SEO
}else{
  $productURL = 'http://www.yoursite.com/catalog(ifapplicable)/product_info.php?products_id=';
}

$already_sent = array();

if(SEO_ENABLED=='true'){
 $home = DB_SERVER;		  //  ****** revised these because we can....
 $user=DB_SERVER_USERNAME;
 $pass=DB_SERVER_PASSWORD;
 $base=DB_DATABASE;
}else{
 $home = "localhost";
 $user="your_db_username";
 $pass="your_db_password";
 $base="name_of_your_db";
}

$ftp_server = "uploads.google.com";
$ftp_user_name = "your_googlebase_username";
$ftp_user_pass = "your_googlebase_password";
$ftp_directory = ""; // leave blank for froogle and google base

$taxRate = 0; //default = 0 (e.g. for 17.5% tax use "$taxRate = 17.5;")
$taxCalc = ($taxRate/100) + 1;  //Do not edit
$convertCur = false; //default = false
$curType = "USD"; // Converts Currency to any defined currency (eg. USD, EUR, GBP)
if($convertCur)
{
  if(SEO_ENABLED=='true'){
   $productParam="currency=" . $curType . "&products_id=";
  }else{
   $productURL = "CHANGEME-http://www.yourwebsite.com/product_info.php?currency=" . $curType . "&products_id=";  //where CURTYPE is your currency type (eg. USD, EUR, GBP)
  }
}

//START Advance Optional Values

//(0=False 1=True) (optional_sec must be enabled to use any options)
$optional_sec = 0;
$currency = 0;
$default_currency = "USD";  //this is not binary.
$location = 0;
$default_location = "your physical address";
$manufacturer = 0;
$upc = 0;   //Not supported by default osC
$manufacturer_id = 0;  //Not supported by default osC
$model_number = 0;
$payment_accepted=0;
  $default_payment_accepted = "cash,check,paypal,visa,mastercard,american express";
$pickup = 0;
  $default_pickup = "Y";   // Y or N
$brand = 0;
$product_type = 0;
$quantity = 0;
$weight = 0;
$delivery_notes = 0;
  $default_delivery_notes = "No delivery available";
$delivery_radius = 0;
  $default_delivery_radius = "10";  // this is not binary
$label=0;   // This will enter keywords based on the cagetories and name
$expiration_date=1;  // not currently supported
  $default_expiration_date=30;  // Number of days before the items expire.

//END of Advance Optional Values

if (!($link=mysql_connect($home,$user,$pass)))
{
echo "Error when connecting itself to the data base";
exit();
}
if (!mysql_select_db( $base , $link ))
{
echo "Error the data base does not exist";
exit();
}

$sql = "
SELECT concat( '" . $productURL . "' ,products.products_id) AS product_url,
products_model AS prodModel, products_weight,
manufacturers.manufacturers_name AS mfgName,
manufacturers.manufacturers_id,
products.products_id AS id,
products_description.products_name AS name,
products_description.products_description AS description,
products.products_quantity AS quantity,
products.products_weight AS weight,
products.products_model as model,
products.products_status AS prodStatus,
FORMAT( IFNULL(specials.specials_new_products_price, products.products_price) * " . $taxCalc . ",2) AS price,
CONCAT( '" . $imageURL . "' ,products.products_image) AS image_url,
products_to_categories.categories_id AS prodCatID,
categories.parent_id AS catParentID,
categories_description.categories_name AS catName
FROM categories,
categories_description,
products,
products_description,
products_to_categories

left join manufacturers on ( manufacturers.manufacturers_id = products.manufacturers_id )
left join specials on ( specials.products_id = products.products_id AND ( ( (specials.expires_date > CURRENT_DATE) OR (specials.expires_date = 0) ) AND ( specials.status = 1 ) ) )

WHERE products.products_id=products_description.products_id
AND products.products_id=products_to_categories.products_id
AND products_to_categories.categories_id=categories.categories_id
AND categories.categories_id=categories_description.categories_id
ORDER BY
products.products_id ASC
";


$catInfo = "
SELECT
categories.categories_id AS curCatID,
categories.parent_id AS parentCatID,
categories_description.categories_name AS catName
FROM
categories,
categories_description
WHERE categories.categories_id = categories_description.categories_id
";

function findCat($curID, $catTempPar, $catTempDes, $catIndex)
{
if( (isset($catTempPar[$curID])) && ($catTempPar[$curID] != 0) )
{
	if(isset($catIndex[$catTempPar[$curID]]))
	{
		$temp=$catIndex[$catTempPar[$curID]];
	}
	else
	{
		$catIndex = findCat($catTempPar[$curID], $catTempPar, $catTempDes, $catIndex);
		$temp = $catIndex[$catTempPar[$curID]];
	}
}
if( (isset($catTempPar[$curID])) && (isset($catTempDes[$curID])) && ($catTempPar[$curID] == 0) )
{
	$catIndex[$curID] = $catTempDes[$curID];
}
else
{
	$catIndex[$curID] = $temp . " > " . $catTempDes[$curID];
}
return $catIndex;

}


$catIndex = array();
$catTempDes = array();
$catTempPar = array();
$processCat = mysql_query( $catInfo )or die( $FunctionName . ": SQL error " . mysql_error() . "| catInfo = " . htmlentities($catInfo) );
while ( $catRow = mysql_fetch_object( $processCat ) )
{
$catKey = $catRow->curCatID;
$catName = $catRow->catName;
$catParID = $catRow->parentCatID;
if($catName != "")
{
	$catTempDes[$catKey]=$catName;
	$catTempPar[$catKey]=$catParID;
}
}

foreach($catTempDes as $curID=>$des)  //don't need the $des
{
$catIndex = findCat($curID, $catTempPar, $catTempDes, $catIndex);
}

$_strip_search = array(
"![\t ]+$|^[\t ]+!m", // remove leading/trailing space chars
'%[\r\n]+%m'); // remove CRs and newlines
$_strip_replace = array(
'',
' ');
$_cleaner_array = array(">" => "> ", "?" => "", "?" => "", "?" => "", "?" => "", "\t" => "", "	" => "");

if ( file_exists( $OutFile ) )
unlink( $OutFile );

$output = "link \t title \t description \t price \t image_link \t category \t id";

//create optional section
if($optional_sec == 1)
{
if($currency ==1)
   $output .= "\t currency ";
if($location == 1)
   $output .= "\t location ";
if($manufacturer==1)
   $output .= "\t manufacturer ";
if($manufacturer_id==1)
   $output .= "\t manufacturer_id ";
if($upc == 1)
	$output .= "\t upc ";
if($model_number==1)
   $output .= "\t model_number ";
if($payment_accepted==1)
   $output .= "\t payment_accepted ";
if($pickup==1)
   $output .= "\t pickup ";
if($product_type==1)
   $output .= "\t product_type ";
if($quantity==1)
   $output .= "\t quantity ";
if($weight==1)
   $output .= "\t weight ";
if($brand == 1)
	$output .= "\t brand ";
if($delivery_notes==1)
	$output .= "\t delivery_notes ";
if($delivery_radius==1)
	$output .= "\t delivery_radius ";
if($expiration_date==1)
	$output .= "\t expiration_date ";
if($label==1)
	$output .= "\t label ";
}
$output .= "\n";


$result=mysql_query( $sql )or die( $FunctionName . ": SQL error " . mysql_error() . "| sql = " . htmlentities($sql) );

//Currency Information
if($convertCur)
{
$sql3 = "
SELECT
currencies.value AS curUSD
FROM
currencies
WHERE currencies.code = '$curType'
";

$result3=mysql_query( $sql3 )or die( $FunctionName . ": SQL error " . mysql_error() . "| sql3 = " . htmlentities($sql3) );
$row3 = mysql_fetch_object( $result3 );
}

$loop_counter = 0;

while( $row = mysql_fetch_object( $result ) )
{
if (isset($already_sent[$row->id])) continue; // if we've sent this one, skip the rest of the while loop

if( $row->prodStatus == 1 || ($optional_sec == 1 && $instock == 1) )
{

	if($convertCur)
	{
		$row->price = ereg_replace("[^.0-9]", "", $row->price);
		$row->price = $row->price *  $row3->curUSD;
		$row->price = number_format($row->price, 2, '.', ',');
	}

	if(SEO_ENABLED=='true'){
			$output .= tep_href_link($productURL,$productParam . $row->id) . "\t" .
			preg_replace($_strip_search, $_strip_replace, strip_tags( strtr($row->name, $_cleaner_array) ) ) . "\t" .
			preg_replace($_strip_search, $_strip_replace, strip_tags( strtr($row->description, $_cleaner_array) ) ) . "\t" .
			$row->price . "\t" .
			$row->image_url . "\t" .
			$catIndex[$row->prodCatID] . "\t" .
			$row->id;
	}else{
	  $output .= $row->product_url . "\t" .
	  preg_replace($_strip_search, $_strip_replace, strip_tags( strtr($row->name, $_cleaner_array) ) ) . "\t" .
	  preg_replace($_strip_search, $_strip_replace, strip_tags( strtr($row->description, $_cleaner_array) ) ) . "\t" .
	  $row->price . "\t" .
	  $row->image_url . "\t" .
	  $catIndex[$row->prodCatID] . "\t" .
	  $row->id;
	}

//optional values section
if($optional_sec == 1)
{
	if($currency==1)
	   $output .= " \t " . $default_currency;
	if($location==1)
	   $output .= " \t " . $default_location;
	if($manufacturer==1)
	   $output .= " \t " . $row->mfgName;
	if($manufacturer_id==1)
	   $output .= " \t " . "Not Supported";
	if($upc==1)
	   $output .= " \t " . "Not Supported";
	if($model_number==1)
	   $output .= " \t " . $row->model;
	if($payment_accepted==1)
	   $output .= " \t " . $default_payment_accepted;
	if($pickup==1)
	   $output .= " \t " . $default_pickup;
	if($product_type==1)
	   $output .= " \t " . $catTempDes[$row->prodCatID];
	if($quantity==1)
	   $output .= " \t " . $row->quantity;
	if($weight==1)
	   $output .= " \t " . $row->weight;
	if($brand==1)
	   $output .= " \t " . $row->mfgName;
	if($delivery_notes==1)
	   $output .= " \t " . $default_delivery_notes;
	if($delivery_radius==1)
	   $output .= " \t " . $delivery_radius;
	if($expiration_date==1)
	   $output .= " \t " . "Not Supported";
	if($label==1)
	   $output .= " \t " . preg_replace($_strip_search, $_strip_replace, strip_tags( strtr($row->name, $_cleaner_array) ) )
						. "," . str_replace(">",",",$catIndex[$row->prodCatID]);
}
$output .= " \n";
}
$already_sent[$row->id] = 1;


$loop_counter++;
if ($loop_counter>750) {
$fp = fopen( $OutFile , "a" );
$fout = fwrite( $fp , $output );
fclose( $fp );
$loop_counter = 0;
$output = "";
}
}

$fp = fopen( $OutFile , "a" );
$fout = fwrite( $fp , $output );
fclose( $fp );
echo "File completed: <a href=\"" . $OutFile . "\" target=\"_blank\">" . $destination_file . "</a><br>\n";
chmod($OutFile, 0777);


//Start FTP to Froogle

function ftp_file( $ftpservername, $ftpusername, $ftppassword, $ftpsourcefile, $ftpdirectory, $ftpdestinationfile )
{
// set up basic connection
$conn_id = ftp_connect($ftpservername);
if ( $conn_id == false )
{
echo "FTP open connection failed to $ftpservername <BR>\n";
return false;
}

// login with username and password
$login_result = ftp_login($conn_id, $ftpusername, $ftppassword);

// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!<BR>\n";
echo "Attempted to connect to " . $ftpservername . " for user " . $ftpusername . "<BR>\n";
return false;
} else {
echo "Connected to " . $ftpservername . ", for user " . $ftpusername . "<BR>\n";
}

if ( strlen( $ftpdirectory ) > 0 )
{
if (ftp_chdir($conn_id, $ftpdirectory )) {
echo "Current directory is now: " . ftp_pwd($conn_id) . "<BR>\n";
} else {
echo "Couldn't change directory on $ftpservername<BR>\n";
return false;
}
}

ftp_pasv ( $conn_id, true );
// upload the file
$upload = ftp_put( $conn_id, $ftpdestinationfile, $ftpsourcefile, FTP_ASCII );

// check upload status
if (!$upload) {
echo "$ftpservername: FTP upload has failed!<BR>\n";
return false;
} else {
echo "Uploaded " . $ftpsourcefile . " to " . $ftpservername . " as " . $ftpdestinationfile . "<BR>\n";
}

// close the FTP stream
ftp_close($conn_id);

return true;
}

ftp_file( $ftp_server, $ftp_user_name, $ftp_user_pass, $source_file, $ftp_directory, $destination_file);

//End FTP to Froogle


//  End TIMER
//  ---------
$etimer = explode( ' ', microtime() );
$etimer = $etimer[1] + $etimer[0];
echo '<p style="margin:auto; text-align:center">';
printf( "Script timer: <b>%f</b> seconds.", ($etimer-$stimer) );
echo '</p>';
//  ---------

?>

Link to comment
Share on other sites

You have an entirely different file than I do...your file is modified to accompany SEO URLs. I had to scroll for miles to see what's in your file, the different parameters I need to change. I have this:

 

$OutFile = "../feeds/nameofmyfile.txt"; 
$destination_file = "nameofmyfile.txt";
$source_file = $OutFile;
$imageURL = 'http://www.nameofmywebsite/com/foldernameforphotos/';
$productURL = 'http://www.nameofmywebsite.com/product_info.php?products_id=';
$already_sent = array();

$home = "localhost";
$user="usernametoaccesscpanel";
$pass="mypassword";
$base="usernametoaccesscpanel_osc2";

$ftp_server = "hedwig.google.com";
$ftp_user_name = "nameofmywebsite";
$ftp_user_pass = "passwordtoaccessgooglebase";
$ftp_directory = ""; // leave blank for froogle

 

 

I know enough that I need to change the ftp_server part to uploads.google.com and apply the username and password for that, but...it's not working. It will not connect. It will generate the .txt file so I can at least save that file in My Documents and attach it manually when I'm signed in to Googlebase, but....that's about it. If I run the feeder it will not connect.

 

No offense, honestly. I appreciate you trying to help me here, I really do.

 

But, the file you displayed and the froogle.php file I have are two different animals and I'm just stuck!

Link to comment
Share on other sites

No offense taken, no problem :)

 

The SEO stuff is all switchable on/off with the statement near the top

 

// Change to 'false' to disable the use of SEO

define('SEO_ENABLED','false');

 

The file is quite different from my froogle.php file as well, just like you found.

 

I remember trying to change the froogle file and not having any luck.

 

I can't remember where I found this one, but it worked....still does. I don't use the SEO stuff on this.

 

Like I said, no problem...I hope you can get it going :)

Link to comment
Share on other sites

Also, the comments in the file are a little confusing in this spot, but in this spot you need your database info, not osc-admin-login info

 

$home = "localhost";

$user="your_db_username";

$pass="your_db_password";

$base="name_of_your_database";

 

That's around line 63.

Link to comment
Share on other sites

Hey! Just wanted to say Thank You for all of your help last night.

 

I tanked on you after my last post and went to bed and awoke today and tried what you suggested.

 

I did replace my existing froogle.php file with yours. But, it still wouldn't connect and upload. It would create the .txt file but would not connect.

 

So, I logged into Googlebase and clicked around a bit and discovered that I no longer had a FTP connection set up. My user ID and password was transferred okay when Froogle turned into Googlebase, but....my FTP connection was nowhere to be found.

 

I wonder now, if I ever needed to replace my froogle.php file with yours. I wonder if all I had to do was re-establish another FTP connection in order to get my feed to work.

 

I did have to do the obvious....change the destination from hedwig.froogle.com to uploads.google.com but...according to Googlebase....I had no FTP account set up anymore.

 

So, I created one again. The same name and password I had used previously. Received a message saying it might take an hour or more for the FTP address to be accessible. So, okay....I let it sit for several hours.

 

Then, I ran the same old command I normally would in my web browser to generate the feed....and all was right with the world again. LOL. With the new uploads.google.com address and the same FTP ID and password I had used previously. They let me set up the FTP anew with the same ID and password I had used previously for my website.

 

I dunno! Just wanted to pass this along for anyone tearing their hair out over why their Froogle feed isn't connecting anymore...despite changing the destination to uploads.google.com

 

In the change from Froogle to Googlebase...it appears they didn't save my FTP account. So, everytime I'd run it...it wouldn't connect. So...login to Googlebase and click on FTP accounts. You may not have one anymore, and will have to re-establish one in order to connect.

 

Thanks again, Choosealogin! I appreciate your help!

Link to comment
Share on other sites

I probably should have thought of that but my situation was a little different. I had separate google base/froogle acconts all along. I didn't realize at the time that they were virtually the same thing (froogle/GB). I was ready to sign up for everything (everything that was free, anyway)...but I couldn't use my froogle login to login to GB. I made a separate FTP acct a few months ago (for GB) and it still works. It would be nice if they had explained that part (dumping your froogle FTP acct). Anyway, I'm glad it's working now!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...