Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

newest googlefeeder.php for google merchant required


duderino3

Recommended Posts

Dear OScommercler.

I´ve got a problem with google merchant and my feeder file for www.ttshop-leipzig.de.

they won´t list me with my products cause i do not have the right attributes in my file like they won´t here: Weitere Informationen

But my products don´t have a GTIN like google want, so i don´t know what to do now.

And there seems to be no up to date addon for this.

Could anybody help me?

Here is my latest googlefeeder.php

<?php

// Title: Google Base / Froogle Data Feeder 2.5

// Last Update: 12/25/09 by Jack_mcs at oscommerce-solution.com

 

/*************** BEGIN MASTER SETTINGS ******************/

define('SEO_ENABLED','true'); //Change to 'false' to disable if Ultimate SEO URLs is not installed

define('FEEDNAME', '***'); //from your googlebase account

define('DOMAIN_NAME', 'www.ttshop-leipzig.de'); //your correct domain name (don't include www unless it is used)

define('FTP_USERNAME', '***'); //created from within your googlebase account

define('FTP_PASSWORD', '.***'); //created from within your googlebase account

define('FTP_ENABLED', '0'); //set to 0 to disable

define('CONVERT_CURRENCY', '0'); //set to 0 to disable - only needed if a feed in a difference currecny is required

define('CURRENCY_TYPE', 'EUR'); //(eg. USD, EUR, GBP)

//define('DEFAULT_LANGUAGE', 0); //Change this to the id of your language. BY default 1 is english

define('QUOTES_CATEGORY_NAME',''); //if the Quotes contribution is installed, enter the name of the quotes category here

 

define('OPTIONS_ENABLED', 1);

define('OPTIONS_ENABLED_AGE_RANGE', 0);

define('OPTIONS_ENABLED_ATTRIBUTES', 0);

define('OPTIONS_ENABLED_BRAND', 0);

define('OPTIONS_ENABLED_CONDITION', 1);

define('OPTIONS_ENABLED_CURRENCY', 0);

define('OPTIONS_ENABLED_FEED_LANGUAGE', 0);

define('OPTIONS_ENABLED_FEED_QUANTITY', 0);

define('OPTIONS_ENABLED_MADE_IN', 0);

define('OPTIONS_ENABLED_MANUFACTURER', 1); //displays the manufacturer name

define('OPTIONS_ENABLED_MPN', 0);

define('OPTIONS_ENABLED_PAYMENT_ACCEPTED', 0);

define('OPTIONS_ENABLED_PRODUCT_MODEL', 1); //displays the product model

define('OPTIONS_ENABLED_PRODUCT_EAN', 1); //displays the products ean

define('OPTIONS_ENABLED_PRODUCT_TYPE', 0);

define('OPTIONS_ENABLED_SHIPPING', 1);

define('OPTIONS_ENABLED_INCLUDE_TAX', 1);

define('OPTIONS_ENABLED_AVAILABILITY', 1);

define('OPTIONS_ENABLED_WEIGHT', 0);

//the following only matter if the matching option is enabled above.

define('OPTIONS_AGE_RANGE', '0-9');

define('OPTIONS_BRAND', '');

define('OPTIONS_CONDITION', 'Neu'); //possible entries are New, Refurbished, Used

define('OPTIONS_DEFAULT_CURRENCY', 'EUR');

define('OPTIONS_DEFAULT_FEED_LANGUAGE', 'en');

define('OPTIONS_LOWEST_SHIPPING', '0'); //this is not binary. Custom Code is required to provide the shipping cost per product. ###needs to be an array for per product.

define('OPTIONS_MADE_IN', 'USA');

define('OPTIONS_MANUFACTURERS_NAME_IGNORE', ''); //list if comma separated manufacturer names to be skipped - e.g. Matrox,Fox

define('OPTIONS_PAYMENT_ACCEPTED_METHODS', ''); //Acceptable values: cash, check, GoogleCheckout, Visa, MasterCard, AmericanExpress, Discover, wiretransfer

define('OPTIONS_TAX_RATE', 19); //default = 0 (e.g. for 17.5% tax use 17.5)

define('OPTIONS_WEIGHT_ACCEPTED_METHODS', 'lb'); //Valid units include lb, pound, oz, ounce, g, gram, kg, kilogram.

/*************** END MASTER SETTINGS ******************/

/*************** NO EDITS NEEDED BELOW THIS LINE *****************/

chdir('../');

include_once 'includes/application_top.php';

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

// Start TIMER

// -----------

$stimer = explode( ' ', microtime() );

$stimer = $stimer[1] + $stimer[0];

// -----------

 

$OutFile = "feeds/" . FEEDNAME;

$destination_file = FEEDNAME;

$source_file = $OutFile;

$imageURL = 'http://' . DOMAIN_NAME . '/images/';

if(SEO_ENABLED=='true'){

$productURL = 'product_info.php'; // ***** Revised for SEO

$productParam = "products_id="; // ***** Added for SEO

}else{

$productURL = 'http://' . DOMAIN_NAME . '/product_info.php?products_id=';

}

$already_sent = array();

$taxCalc = (OPTIONS_ENABLED_INCLUDE_TAX ? (OPTIONS_TAX_RATE/100) + 1 : 1); //Do not edit

if(CONVERT_CURRENCY)

{

if(SEO_ENABLED=='true'){

$productParam="currency=" . CURRENCY_TYPE . "&products_id=";

}else{

$productURL = "http://" . DOMAIN_NAME . "/product_info.php?currency=" . CURRENCY_TYPE . "&products_id="; //where CURRENCY_TYPE is your currency type (eg. USD, EUR, GBP)

}

}

$feed_exp_date = date('Y-m-d', time() + 2505600 );

$quotes = '';

if (QUOTES_CATEGORY_NAME !== '') {

$quotes = " and products.customers_email_address = '' and products.quotes_email_address = ''";

}

$sql = "

SELECT concat( '" . $productURL . "' ,products.products_id) AS product_url,

products_model AS prodModel,

products_ean AS prodEAN,

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_status AS prodStatus,

products.products_weight AS prodWeight,

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 is NULL) 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 " . $quotes . "

AND categories_description.language_id = " . $languages_id . "

AND products_description.language_id = " . $languages_id . "

ORDER BY

products.products_id ASC

";

$quotes = '';

if (QUOTES_CATEGORY_NAME !== '') {

$quotes = " and categories_description.categories_name NOT LIKE '" . QUOTES_CATEGORY_NAME . "' ";

}

$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 " . $quotes . "

AND categories_description.language_id = " . $languages_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 = tep_db_query( $catInfo );

while ( $catRow = tep_db_fetch_array( $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\ttitel\tbeschreibung\tverfallsdatum\tpreis\timage_link\tproduct_type\tid";

$attributesColumns = array();

//create optional section

if(OPTIONS_ENABLED == 1)

{

if(OPTIONS_ENABLED_AGE_RANGE == 1)

$output .= "\tage_range";

if(OPTIONS_ENABLED_BRAND == 1)

$output .= "\tbrand";

if(OPTIONS_ENABLED_CONDITION == 1)

$output .= "\tzustand";

if(OPTIONS_ENABLED_CURRENCY == 1)

$output .= "\tcurrency";

if(OPTIONS_ENABLED_FEED_LANGUAGE == 1)

$output .= "\tlanguage";

if(OPTIONS_ENABLED_FEED_QUANTITY == 1)

$output .= "\tquantity";

if(OPTIONS_ENABLED_MADE_IN == 1)

$output .= "\tmade_in";

if(OPTIONS_ENABLED_MANUFACTURER == 1)

$output .= "\tmanufacturer";

if(OPTIONS_ENABLED_MPN == 1)

$output .= "\tmpn";

if(OPTIONS_ENABLED_PAYMENT_ACCEPTED == 1)

$output .= "\tpayment_accepted";

if(OPTIONS_ENABLED_PRODUCT_MODEL == 1)

$output .= "\tmpn";

if(OPTIONS_ENABLED_PRODUCT_EAN == 1)

$output .= "\tean";

if(OPTIONS_ENABLED_PRODUCT_TYPE == 1)

$output .= "\tproduct_type";

if(OPTIONS_ENABLED_SHIPPING == 1)

$output .= "\tshipping";

if(OPTIONS_ENABLED_AVAILABILITY == 1)

$output .= "\tavailability";

if(OPTIONS_ENABLED_WEIGHT == 1)

$output .= "\tweight";

if (OPTIONS_ENABLED_ATTRIBUTES == 1)

{

$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from products_options popt, products_attributes patrib where popt.language_id = '" . (int)1 . "' order by popt.products_options_name") or die(mysql_error());

while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

$attributesColumns[] = $products_options_name['products_options_name'];

$name = strtolower($products_options_name['products_options_name']);

$name = str_replace(" ","_", $name);

$output .= "\tc:" . $name;

}

/*

//If you want to only show particular attributes, comment out the above and uncomment this section.

//Then enter two lines for each one you want to show. For example, if the atttributes you want to

//show are named Color and Fabric, the entries would appear as follows:

$attributesColumns[] = "Color";

$attributesColumns[] = "Fabric";

$output .= "\tc:" . strtolower("Color");

$output .= "\tc:" . strtolower("Fabric");

*/

}

}

$output .= "\n";

 

$result=tep_db_query( $sql );

//Currency Information

if(CONVERT_CURRENCY)

{

$sql3 = "

SELECT

currencies.value AS curUSD

FROM

currencies

WHERE currencies.code = '" . CURRENCY_TYPE . "'";

$result3=tep_db_query( $sql3 );

$row3 = tep_db_fetch_array( $result3 );

}

$loop_counter = 0;

while( $row = tep_db_fetch_array( $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 || (OPTIONS_ENABLED == 1 && $quantity == 1) )

{

if (CONVERT_CURRENCY)

{

$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'], 'NONSSL', false) . "\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" .

$feed_exp_date . "\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" .

$feed_exp_date . "\t" .

$row['price'] . "\t" .

$row['image_url'] . "\t" .

$catIndex[$row['prodCatID']] . "\t" .

$row['id'];

}

//optional values section

if(OPTIONS_ENABLED == 1)

{

if(OPTIONS_ENABLED_AGE_RANGE == 1)

$output .= " \t " . OPTIONS_AGE_RANGE;

if(OPTIONS_ENABLED_BRAND == 1)

$output .= " \t " . OPTIONS_BRAND;

if(OPTIONS_ENABLED_CONDITION == 1)

$output .= " \t " . OPTIONS_CONDITION;

if(OPTIONS_ENABLED_CURRENCY == 1)

$output .= " \t " . OPTIONS_DEFAULT_CURRENCY;

if(OPTIONS_ENABLED_FEED_LANGUAGE == 1)

$output .= " \t " . OPTIONS_DEFAULT_FEED_LANGUAGE;

if(OPTIONS_ENABLED_FEED_QUANTITY == 1)

$output .= " \t " . $row['quantity'];

if(OPTIONS_ENABLED_MADE_IN == 1)

$output .= " \t " . OPTIONS_MADE_IN;

if(OPTIONS_ENABLED_MANUFACTURER == 1)

$output .= " \t " . (in_array($row['mfgName'],explode(",",OPTIONS_MANUFACTURERS_NAME_IGNORE)) ? '' : $row['mfgName']);

if(OPTIONS_ENABLED_PAYMENT_ACCEPTED == 1)

$output .= " \t " . OPTIONS_PAYMENT_ACCEPTED_METHODS;

if(OPTIONS_ENABLED_PRODUCT_MODEL == 1)

$output .= " \t " . $row['prodModel'];

if(OPTIONS_ENABLED_MPN == 1)

$output .= " \t " . OPTIONS_MPN;

if(OPTIONS_ENABLED_PRODUCT_EAN == 1)

$output .= "\t" . $row->prodEAN;

if(OPTIONS_ENABLED_PRODUCT_TYPE == 1)

{

$catNameTemp = strtolower($catName);

$output .= " \t " . $row['catName'];

}

if(OPTIONS_ENABLED_SHIPPING == 1)

$output .= " \t " . OPTIONS_LOWEST_SHIPPING;

if(OPTIONS_ENABLED_AVAILABILITY == 1)

$output .= " \t " . "available for order";

if(OPTIONS_ENABLED_WEIGHT == 1)

$output .= " \t " . $row['prodWeight'] . ' ' .OPTIONS_WEIGHT_ACCEPTED_METHODS;

/******************* BEGIN HANDLING THE ATTRIBUTES ********************/

if (OPTIONS_ENABLED_ATTRIBUTES == 1)

{

$products_attributes_query = tep_db_query("select count(*) as total from products_options popt, products_attributes patrib where patrib.products_id='" . $row['id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)1 . "'");

$products_attributes = tep_db_fetch_array($products_attributes_query);

if ($products_attributes['total'] > 0) {

$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from products_options popt, products_attributes patrib where patrib.products_id='" . (int)$row['id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)1 . "' order by popt.products_options_name") or die(mysql_error());

$trackTabs = '';

while ($products_options_name = mysql_fetch_object($products_options_name_query)) {

$products_options_array = array();

$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from products_attributes pa, products_options_values pov where pa.products_id = '" . (int)$row['id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)1 . "'");

while ($products_options = tep_db_fetch_array($products_options_query)) {

$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

}

for ($a = 0; $a < count($attributesColumns); ++$a)

{

if ($products_options_name['products_options_name'] == $attributesColumns[$a])

{

if ($a == 0)

$trackTabs = "\t";

else

{

if (empty($trackTabs))

$trackTabs = str_repeat("\t", $a);

$trackTabs .= "\t";

}

$output .= $trackTabs;

foreach ($products_options_array as $arr)

$output .= $arr['text'] . ',';

$output = substr($output, 0, -1);

}

}

}

}

}

/******************* END HANDLING THE ATTRIBUTES ********************/

}

$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=\"" . tep_href_link( $OutFile ) . "\" target=\"_blank\">" . $destination_file . "</a><br>\n";

chmod($OutFile, 0777);

 

//Start FTP

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;

}

if (FTP_ENABLED)

ftp_file( "uploads.google.com", FTP_USERNAME, FTP_PASSWORD, $source_file, "", $destination_file);

//End FTP

 

// 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>';

// ---------

include_once 'includes/application_bottom.php';

?>

 

many thanks

Link to comment
Share on other sites

Hi Jack.

 

Thanks for your post, but it can´t be the new one that fits to the newest conditions from google for products, cause there is no gtin included etc.

 

the last update for this is from 2012 and the latest change from google was july 2013.

 

Do you have an idea how i can insert the latest needs from this page? https://support.google.com/merchants/answer/188494?hl=de

 

Thx

Link to comment
Share on other sites

  • 4 months later...

Hello Googlefeeder Users

 

On January 3, 2014 Google did it again!

I had finally worked out the kinks and had Google Adwords in sync with my Google Merchant account and I was getting a reasonable number of hits daily. I was increasing my product listing Adwords and could see that 2014 was going to be a Great year.

 

Then I noticed that on the 3rd, 4th & 5th I did not have one hit. You guessed it. Google got every penny due on my account and then shut it down. If you thought the Google Product Feed Specifications and the Summary of Attribute Requirements were getting tougher well now every product must have a unique (never to be changed, permanent) ID (can't use Model anymore) and they will not take any product without an image. I suspect all the Google Product Categories must literally match a line item in their taxonomy.

 

So here's the problem. Googlefeeder.php needs to work for those of us who are on Version 2.3.3.4 as a contribution by Jack or as part of 2.3.3.5. Needless to say, THIS IS A REALLY REALLY REALLY HIGH PRIORITY!!!!!!!!! If we have to wait for it to be incorporated into 2.3.3.5 we also need Easy Populate added in also.

 

As Mr Ross Perot would say, "I'm all ears." Tell me what we are going to do.

Joseph E. "Joe" Stephenson
[email protected]

Link to comment
Share on other sites

  • 1 month later...

This will probably never be core to OSC as not everybody uses google feeds - it will probably remain an add-on forever - there is a comprehensive support thread for google feeder which is very well supported by Jack.

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...