Jump to content
gottaloveit

Automatically send data feed to Froogle

Recommended Posts

Couple of changes that may be useful if you plan to use the .csv file for the Google Merchant Center (GMC).

 

GMC is using  date format Y-m-d, so I changed the line 
 

define('OPTIONS_DATE_FORMAT', 'm-d-Y');         //change how the date is formatted

to

define('OPTIONS_DATE_FORMAT', 'Y-m-d');         //change how the date is formatted

 

Since GMC requires the price field to have the curency specified (i.e. '19.99 USD'), near line 465 I replaced 

$row->price . "\t" .

with

$row->price . ' ' . OPTIONS_CURRENCY . "\t" .

 

Near line 627

$csvStr = str_replace("\t", '", "', '"' . $output);
$csvStr = str_replace("\n", "\"\n\"", $csvStr);
$csvStr = substr($csvStr,0,-1);
$csvStr = str_replace("\t", '", "', '"' . $output . '"');

I escaped the last line

#$csvStr = str_replace("\t", '", "', '"' . $output . '"');

 

And finally I replaced the below three lines

$fp = fopen( $csvFileLocn , "a" );
$fout = fwrite( $fp , $csvStr );
fclose( $fp );

with 

file_put_contents($csvFileLocn, $csvStr);

 

I think that was it.

Hope this will help someone.

Share this post


Link to post
Share on other sites

Thanks for posting those changes. But as mentioned on the map creation page, the csv file is for testing only. You can use it if your fixes make it a working file but I suggest downloading It and try opening it locally to make sure it works.

Share this post


Link to post
Share on other sites
10 minutes ago, Jack_mcs said:

Thanks for posting those changes. But as mentioned on the map creation page, the csv file is for testing only. You can use it if your fixes make it a working file but I suggest downloading It and try opening it locally to make sure it works.

You are absolutely right, it say for testing only. However, since I needed it I worked on it and tested. The data is successfully uploaded to GMC. So I thought someone else may benefit from it too. 

 Otherwise, thanks for the module. It works fine for me.

Share this post


Link to post
Share on other sites

i try to install google feeder in lat phenix version but , i have this error

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /archivio/html/osnew/admin/googlefeeder.php on line 311

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /archivio/html/osnew/admin/googlefeeder.php on line 410

Feed contains 0 products.

 

can you help me?

Enrico

Share this post


Link to post
Share on other sites

@Adam_MaynardSee my email.

@bitit.itThe code tries to figure out which php version is being used. I looks like it thinks you are using a version that used MySQL. Try changing this line in the googlefeeder.php file

$myfetch_mysql = ($use_mysqli ? mysqli_fetch_object : mysql_fetch_object);

to

$myfetch_mysql = mysqli_fetch_object;

 

Share this post


Link to post
Share on other sites

at the moment i have a test version with php 5.6.4  but i want put production with php7.1 minimum .

In this way seem work in both version.

Thank you

Enrico

 

 

Share this post


Link to post
Share on other sites

can i suggest a little change :

define('FEEDNAME', $language.'-your-outfile.txtt');       //from your googlebase account

instead of

define('FEEDNAME', '-your-outfile.txt');       //from your googlebase account

because if i want make two different campaign with two different language in this way i  can create different feed for any language.

following i want try to create a new interface , changing the link for create the feed in a form  where is possible select any active language.

and change in

define('FEEDNAME', $getLanguage.'-your-outfile.txtt');       //from your googlebase account

 

Enrico

 

Share this post


Link to post
Share on other sites

for the moment the best should be

define('FEEDNAME', $language.'-your-outfile.txtt');  // where $language is default language

define('DEFAULT_LANGUAGE_ID', $languages_id);   //Default id Language

define('OPTIONS_FEED_LANGUAGE', $defaultcodelanguage); //

do you know  real name of this variable?

alternatively i have create a query on top of the file that give me this variables

Enrico

 

 

Share this post


Link to post
Share on other sites

very simple change feed  language ,   changing the order of language

$query_lang_bitit=tep_db_query('SELECT * FROM languages ORDER BY sort_order');

$result_lang_bitit= mysqli_fetch_array($query_lang_bitit);

$language_id_bitit= $result_lang_bitit['languages_id'];
$language_code_bitit= $result_lang_bitit['code'];
$language_bitit= $result_lang_bitit['name'];

 

define('FEEDNAME', $language_bitit.'-your-outfile.txtt');  // 

define('DEFAULT_LANGUAGE_ID', $language_id_bitit);   //

define('OPTIONS_FEED_LANGUAGE', $language_code_bitit); //

 

Share this post


Link to post
Share on other sites

Hello.. another problem . google shopping want https pages for starting the advertise ; i have do some edit about :

around line 134

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

 + $imageURL = 'https://' . DOMAIN_NAME . '/images/';

around line 139

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

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

around line 149

-   $productURL = "http://" . DOMAIN_NAME . "/product_info.php?currency=" . CURRENCY_TYPE . "&products_id=";  //where

+   $productURL = "https://" . DOMAIN_NAME . "/product_info.php?currency=" . CURRENCY_TYPE . "&products_id=";  //where

the image address have  correctly https, but  the product url keep to be http

have you some idea?

Enrico

Share this post


Link to post
Share on other sites

If you have the SEO_ENABLED setting set to true, then you may need to change the tep_href_link to tep_catalog_href_link. If not, the only thing I can think of is that your shop is not set up to work fully with ssl. Be sure there is redirect code in the roots .htaccess file to redirect to https.

Share this post


Link to post
Share on other sites

yes , excuse me;

  i believe is a bug of phenix1010 version ;   for work , must setup the configure file  in the following way

  define('HTTP_SERVER', 'https://eshop.olivierasantangelo.it');
  define('HTTPS_SERVER', 'https://eshop.olivierasantangelo.it');

both define with https://

thank you again

Enrico

Share this post


Link to post
Share on other sites

Trying out this module

After many hrs, still no stuck

The txt file created there is a missing tab between expiration_date and model  - gmc is refusing the feed - Too many column delimiters

link	title	description	price	image_link	id	availability	brand	condition	currency	expiration_date	model	shipping	tax	shipping_weight

  the tab is specified in below

         if(OPTIONS_ENABLED_EXPIRATION == 1)
            $output .= "\t" . $feed_exp_date;
         if(OPTIONS_ENABLED_PRODUCT_MODEL == 1)
            $output .= "\t" . (! empty($row->prodModel) ? $row->prodModel : $row->catName);

How to fix?

Anyone who has current working example, please share 

Also @Jack_mcs

Is these values correct for 15% VAT:

define('OPTIONS_SHIPPING_STRING', 'ZA:Ground:95.00:yes'); //says charge shipping to US for residents of Florida at 5% and don't apply tax to shipping

define('OPTIONS_TAX_RATE' , '15'); //default = 0 (e.g. for 20.0% tax use "$taxRate = 20.0;")  //only used in the next line
define('OPTIONS_TAX_CALC', (OPTIONS_ENABLED_INCLUDE_TAX == 2 ? (OPTIONS_TAX_RATE/100) + 1 : '1')); //UK. US tax rate - US is ignorded since it is 1

Please have a look


Getting the Phoenix off the ground

Share this post


Link to post
Share on other sites

Correct me if i'm wrong:

   if(OPTIONS_ENABLED_INCLUDE_TAX == 1 || OPTIONS_ENABLED_INCLUDE_TAX == 2) $output .= "\ttax";

if option is a 1 or 2 - tax is shown.

below only option 1 is output but not 2
         if(OPTIONS_ENABLED_INCLUDE_TAX == 1)
            $output .= "\t" . OPTIONS_TAX_STRING;


added 2nd part for custom tax to show

         if(OPTIONS_ENABLED_INCLUDE_TAX == 2)
            $output .= "\t" . OPTIONS_TAX_STRING;


Getting the Phoenix off the ground

Share this post


Link to post
Share on other sites

Hi

 

no a coder, in UK 20% vat standard rate

 

i have at different parts  of the page

define('OPTIONS_ENABLED_INCLUDE_TAX', 2);       //0 = no tax, 1 = uses google method, 2 = UK Vat
 

.......................................

 

define('OPTIONS_TAX_RATE' , '20.0'); //default = 0 (e.g. for 20.0% tax use "$taxRate = 20.0;")  //only used in the next line
define('OPTIONS_TAX_CALC', (OPTIONS_ENABLED_INCLUDE_TAX == 2 ? (OPTIONS_TAX_RATE/100) + 1 : '1')); //UK. US tax rate - US is ignorded since it is 1
 

....................

 

if(OPTIONS_ENABLED_INCLUDE_TAX == 1 || OPTIONS_ENABLED_INCLUDE_TAX == 3) $output .= "\ttax";

 

......................................

 

      if (OPTIONS_ENABLED_INCLUDE_TAX == 3) {
          $db_query = tep_db_query("select tax_rate from " . TABLE_TAX_RATES . " where tax_rates_id = " . (int)$row->tax_id);
          $db = tep_db_fetch_array($db_query);
          if ($db['tax_rate'] > 0) {
              $price_w_tax = $row->price_no_tax + (round($row->price_no_tax * ($db['tax_rate']/100),2));
              //echo 'price '.$row->id. ' W TAX= ' . $row->price . ' No Tax=  '.$row->price_no_tax .' CALC= '. $price_w_tax . ' ' .$row->tax_id.'<br>';
              $row->price = $price_w_tax;
          } //else price uses the default tax
      } //else price uses the default tax  
 

............................

 if(OPTIONS_ENABLED_INCLUDE_TAX == 1)
            $output .= "\t" . OPTIONS_TAX_STRING;

 

Not sure if i have edited this myself of found it in the forums, but it works

 

I have some items that are zero vat rated, so it may be different


David


David

Share this post


Link to post
Share on other sites

Tip:
Setting up cronjob was problematic
Changed in beginning of file chdir('../'); to full server root 
chdir('/usr/www/users/yourservernamehere/');


Getting the Phoenix off the ground

Share this post


Link to post
Share on other sites

@DAVID3733

Strange, that must have been added later on, i see nothing my side to option 3

1 hour ago, DAVID3733 said:

ENABLED_INCLUDE_TAX == 3

Looks like good fix rather using the db tax than i hardcoded


Getting the Phoenix off the ground

Share this post


Link to post
Share on other sites
3 hours ago, Peper said:

The txt file created there is a missing tab between expiration_date and model  - gmc is refusing the feed - Too many column delimiters

You can turn the expiration date off. It is only useful if you are submitting products that will expire in less than 30 days. That probably won't fix the problem but may help you find it. You have to determine what data is missing. You can usually do that by looking at the contents of each column. For example, if the column is for price and it shows a date, then the price data is missing.

2 hours ago, Peper said:

added 2nd part for custom tax to show

This is not correct. The option 2 is handled in a different part of the code.

Share this post


Link to post
Share on other sites
18 minutes ago, Jack_mcs said:

You can turn the expiration date off. It is only useful if you are submitting products that will expire in less than 30 days. That probably won't fix the problem but may help you find it. You have to determine what data is missing. You can usually do that by looking at the contents of each column. For example, if the column is for price and it shows a date, then the price data is missing.

This is not correct. The option 2 is handled in a different part of the code.

The missing part was tax for each product
The tax is calculating correctly

      if (OPTIONS_ENABLED_INCLUDE_TAX == 2) {
          $db_query = tep_db_query("select tax_rate from " . TABLE_TAX_RATES . " where tax_rates_id = " . (int)$row->tax_id);

............

So now you have:

   if(OPTIONS_ENABLED_INCLUDE_TAX == 1 || OPTIONS_ENABLED_INCLUDE_TAX == 2) $output .= "\ttax";
   if(OPTIONS_ENABLED_UPC == 1)                 $output .= "\tupc";
   if(OPTIONS_ENABLED_WEIGHT == 1)              $output .= "\tshipping_weight";

1st line will show tax heading - TAX == 1 and 2

but then here:

         if(OPTIONS_ENABLED_INCLUDE_TAX == 1)
            $output .= "\t" . OPTIONS_TAX_STRING;
         if(OPTIONS_ENABLED_UPC == 1)
            $output .= "\t" . (isset($row->upc) ? $row->upc : (strlen(OPTIONS_UPC) ? OPTIONS_UPC : "Not Supported"));
         if(OPTIONS_ENABLED_WEIGHT == 1)
            $output .= "\t" . $row->prodWeight . ' ' .OPTIONS_WEIGHT_ACCEPTED_METHODS;

only TAX==1
the tax heading is shown but no output for each product TAX==2

added TAX==2
         if(OPTIONS_ENABLED_INCLUDE_TAX == 2)
            $output .= "\t" . OPTIONS_TAX_STRING;


Getting the Phoenix off the ground

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×