Editting Google Base Attributes

You will find most of the attributes within: /root/include/admin/exim/exim.google.php



I was looking for this because I wanted to add more information to my google base products mainly the manufacturer part number (mpn) also known as Product Code. What I found is that CS has set the UPC code for product code. I simply changed upc to mpn. Easy enough fix.


	'#override_options' => array (<br />
		'delimiter' => 'T',<br />
		'output' => 'S',<br />
	),<br />
	'#post_processing' => array ('fn_exim_transfer_google_file', '@filename'),<br />
	'#export_fields' => array (<br />
		'id' => array (<br />
			'#db_field' => 'product_id',<br />
			'#required' => true,<br />
			'#alt_key' => true<br />
		),<br />
		'product_type' => array (<br />
			'#process_get' => array('fn_exim_google_format_field', '', 'product_type', '', '@product_type'),<br />
			'#linked' => false<br />
		),<br />
		'quantity' => array (<br />
			'#db_field' => 'amount'<br />
		),<br />
		'price' => array (<br />
			'#table' => 'product_prices',<br />
			'#db_field' => 'price',<br />
			'#process_get' => array('fn_exim_google_format_field', '#this', 'price', '#key', '@discounts')<br />
		),<br />
		'mpn' => array (   [COLOR="Magenta"]<--------------------------------------[/COLOR]<br />
			'#db_field' => 'product_code'<br />
		),<br />
		'title' => array (<br />
			'#table' => 'product_descriptions',<br />
			'#db_field' => 'product',<br />
			'#process_get' => array('fn_exim_google_format_field', '#this', 'title'),<br />
		),<br />
		'description' => array (<br />
			'#table' => 'product_descriptions',<br />
			'#db_field' => 'full_description',<br />
			'#process_get' => array('fn_exim_google_format_field', '#this', 'description'),<br />
		),<br />
		'link' => array (<br />
			'#process_get' => array ('fn_exim_get_product_url', '#key'),<br />
			'#linked' => false<br />
		),<br />
		'image_link' => array (<br />
			'#process_get' => array ('fn_exim_get_image_url', '#this', 'product'),<br />
			'#db_field' => 'image_id',<br />
			'#table' => 'product_images_links',<br />
		),<br />
// Please uncomment this code if you want to export ISBN feature to the google<br />
/*		'ISBN' => array (   [COLOR="Magenta"]<----------------------------------------------[/COLOR]<br />
			'#process_get' => array ('fn_exim_get_feature', '#key', 'ISBN'),<br />
			'#linked' => false<br />
		),*/<br />
	),<br />
);
```<br />
<br />
If you notice, you can uncomment the line above to add ISBN to the attributes.  Now what I don't understand is there are 2 different kinds of bar codes.  ISBN is for books only and UPC is for all others.  I don't sell books but I am not sure if you can use the barcode add on for each?<br />
<br />
<br />
Also if you use 1 product type for all of your products then look further down in the script and put your product type at the top of the list so you don't have to keep scrolling through the list each time you submit to google base.  All of my products are tool related so that is what I put at the top of the list.<br />
<br />
```php
function fn_exim_google_get_types()<br />
{<br />
	return array (<br />
                [COLOR="Magenta"]'tools' => 'tools',[/COLOR]<br />
		'other' => 'other',<br />
		'2-way radios' => '2-way radios',
```<br />
<br />
<br />
<br />
I also noticed that if you need to alter some of the attibutes for addons, you will need to go into the addons folder to change the attribute.  For example I wanted to change the attribute name for manufacturers.  Currently it is set as "brand".  To make it "manufacturer" instead of "brand" I made the changes in [I][B]/root/addons/manufacturers/include/admin/exim/exim.google.php[/B][/I].<br />
<br />
```php
//<br />
// Schema definition<br />
//<br />
<br />
$pattern['#export_fields']['[COLOR="Magenta"]manufacturer[/COLOR]'] = array (<br />
	'#db_field' => 'manufacturer_id',<br />
	'#process_get' => array ('fn_exim_get_g_manufacturer', '#this', '@lang_code'),<br />
);
```<br />
<br />
Anyway, this is basically how you can edit the google base attributes. I know some have been inquiring about doing this and if you feel comfortable about playing around with this, then this is where you want to be editting.

Here are all of my changes for Google Base. I had to shave the “Product type” list to make this postable.



The file is [COLOR=“blue”]/include/admin/exim/exim.google.php[/COLOR]. This makes some corrections but the main thing it does is adds “Product condition: New/Used/Other”.





[ATTACH]959[/ATTACH]






```php
/******************************************************************************

  •                                                                         *
  •       Copyright (c) 2004-2007 CS-Cart.com. All rights reserved.         *
  •                                                                         *

*******************************************************************************

  •                                                                         *
  • CS-Cart is commercial software, only users who have purchased a valid *
  • license through https://www.cs-cart.com/ and accept to the terms of this *
  • License Agreement can install this product. *
  •                                                                         *

*******************************************************************************

  • THIS CS-CART SHOP END-USER LICENSE AGREEMENT IS A LEGAL AGREEMENT BETWEEN *
  • YOU AND YOUR COMPANY (COLLECTIVELY, “YOU”) AND CS-CART.COM (HEREINAFTER *
  • REFERRED TO AS “THE AUTHOR”) FOR THE SOFTWARE PRODUCT IDENTIFIED ABOVE, *
  • WHICH INCLUDES COMPUTER SOFTWARE AND MAY INCLUDE ASSOCIATED MEDIA, PRINTED *
  • MATERIALS, AND “ONLINE” OR ELECTRONIC DOCUMENTATION (COLLECTIVELY, THE *
  • “SOFTWARE”). BY USING THE SOFTWARE, YOU SIGNIFY YOUR AGREEMENT TO ALL *
  • TERMS, CONDITIONS, AND NOTICES CONTAINED OR REFERENCED HEREIN. IF YOU ARE *
  • NOT WILLING TO BE BOUND BY THIS AGREEMENT, DO NOT INSTALL OR USE THE *
  • SOFTWARE. *
  •                                                                         *
  • PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE “COPYRIGHT” *
  • FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE *
  • AT THE FOLLOWING URL: License Agreement on the Use of CS-Cart *

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



    //

    // $Id: exim.google.php 4398 2007-12-06 13:46:24Z zeke $

    //



    if ( !defined(‘IN_CSCART’) ) { die(‘Access denied’); }



    //

    // Schema definition

    //

    $pattern = array (

    ‘#section’ => ‘products’,

    ‘#key’ => array(‘product_id’),

    ‘#enclosure’ => ‘’,

    ‘#name’ => fn_get_lang_var(‘google_base’),

    ‘#pattern_id’ => ‘google’,

    ‘#table’ => ‘products’,

    ‘#condition’ => array(‘avail’ => ‘Y’),

    ‘#export_only’ => true,

    ‘#range_options’ => array (

    ‘#selector_url’ => “$GLOBALS[index_script]?$GLOBALS[target_name]=products&$GLOBALS[mode_name]=manage”,

    ‘#object_name’ => fn_get_lang_var(‘products’),

    ),

    ‘#references’ => array (

    ‘product_descriptions’ => array (

    ‘#reference_fields’ => array (‘product_id’ => ‘#key’, ‘lang_code’ => ‘@lang_code’),

    ‘#join_type’ => ‘LEFT’

    ),

    ‘product_prices’ => array (

    ‘#reference_fields’ => array (‘product_id’ => ‘#key’, ‘lower_limit’ => 1, ‘membership_id’ => 0),

    ‘#join_type’ => ‘LEFT’

    ),

    ‘product_images_links’ => array (

    ‘#reference_fields’ => array(‘product_id’ => ‘#key’, ‘type’ => ‘M’),

    ‘#join_type’ => ‘LEFT’

    ),

    ),

    ‘#options’ => array (

    ‘lang_code’ => array (

    ‘title’ => ‘language’,

    ‘type’ => ‘languages’

    ),

    ‘product_type’ => array (

    ‘title’ => ‘product_type’,

    ‘type’ => ‘select’,

    ‘variants_function’ => ‘fn_exim_google_get_types’,

    ),

    [COLOR=“Blue”] ‘condition’ => array (

    ‘title’ => ‘product_condition’,

    ‘type’ => ‘select’,

    ‘variants_function’ => ‘fn_exim_google_get_conditions’,

    ),[/COLOR]

    ‘discounts’ => array (

    ‘title’ => ‘export_discounts’,

    ‘type’ => ‘checkbox’

    ),

    ),

    ‘#override_options’ => array (

    ‘delimiter’ => ‘T’,

    ‘output’ => ‘S’,

    ),

    ‘#post_processing’ => array (‘fn_exim_transfer_google_file’, ‘@filename’),

    ‘#export_fields’ => array (

    ‘id’ => array (

    ‘#db_field’ => ‘product_id’,

    ‘#required’ => true,

    ‘#alt_key’ => true

    ),

    ‘product type’ => array (

    ‘#process_get’ => array(‘fn_exim_google_format_field’, ‘’, ‘product_type’, ‘’, ‘@product_type’),

    ‘#linked’ => false

    ),

    [COLOR=“Blue”] ‘condition’ => array (

    ‘#process_get’ => array(‘fn_exim_google_format_field’, ‘’, ‘condition’, ‘’, ‘@condition’),

    ‘#linked’ => false

    ),[/COLOR]

    ‘quantity’ => array (

    ‘#db_field’ => ‘amount’

    ),

    [COLOR=“Blue”]‘weight’ => array (

    ‘#db_field’ => ‘weight’

    ),[/COLOR]

    ‘price’ => array (

    ‘#table’ => ‘product_prices’,

    ‘#db_field’ => ‘price’,

    ‘#process_get’ => array(‘fn_exim_google_format_field’, ‘#this’, ‘price’, ‘#key’, ‘@discounts’)

    ),

    ‘[COLOR=“blue”]mpn[/COLOR]’ => array (

    ‘#db_field’ => ‘product_code’

    ),

    ‘title’ => array (

    ‘#table’ => ‘product_descriptions’,

    ‘#db_field’ => ‘product’,

    ‘#process_get’ => array(‘fn_exim_google_format_field’, ‘#this’, ‘title’),

    ),

    ‘description’ => array (

    ‘#table’ => ‘product_descriptions’,

    ‘#db_field’ => ‘full_description’,

    ‘#process_get’ => array(‘fn_exim_google_format_field’, ‘#this’, ‘description’),

    ),

    ‘link’ => array (

    ‘#process_get’ => array (‘fn_exim_get_product_url’, ‘#key’),

    ‘#linked’ => false

    ),

    ‘image_link’ => array (

    ‘#process_get’ => array (‘fn_exim_get_image_url’, ‘#this’, ‘product’),

    ‘#db_field’ => ‘image_id’,

    ‘#table’ => ‘product_images_links’,

    ),

    // Please uncomment this code if you want to export ISBN feature to the google

    /
    ‘ISBN’ => array (

    ‘#process_get’ => array (‘fn_exim_get_feature’, ‘#key’, ‘ISBN’),

    ‘#linked’ => false

    ),
    /

    ),

    );





    $CALLER = FILE;

    include CORE_DIR . ‘include_addons.php’;



    // ------------- Utility functions ---------------



    //

    // Get product url

    // Parameters:

    // @product_id - product ID



    function fn_exim_get_product_url($product_id, $options = ‘’)

    {

    global $db_tables;

    global $http_location, $customer_index, $target_name;



    $url = $http_location .‘/’. $customer_index . “?$target_name=products&product_id=$product_id”;



    $function = FUNCTION;

    include CORE_DIR . ‘addons_inheritance.php’;



    return $url;

    }



    //

    // This function get the feature value

    function fn_exim_get_feature($product_id, $feature_name)

    {

    global $db_tables, $cart_language;



    $feature = db_get_field(“SELECT value FROM $db_tables[product_features_values] as a LEFT JOIN $db_tables[product_features_descriptions] as b ON a.feature_id=b.feature_id AND b.lang_code=‘$cart_language’ WHERE b.description=‘$feature_name’ AND a.product_id=‘$product_id’ AND a.lang_code=‘$cart_language’”);



    return $feature;

    }



    //

    // Formats field by its type

    // Parameters:

    // @data - field to be formatted

    // @type - field type

    function fn_exim_google_format_field($data, $type, $product_id = 0, $option = ‘’)

    {

    if ($type == ‘product’) {

    return substr(strip_tags($data), 0, 80);



    } elseif ($type == ‘product_type’) {

    return (!empty($option)) ? $option : ‘Other’;



    [COLOR=“blue”]} elseif ($type == ‘condition’) {

    return (!empty($option)) ? $option : ‘Other’;[/COLOR]



    } elseif ($type == ‘price’) {

    $_auth = array(‘user_id’ => 0, ‘membership_id’ => 0, ‘tax_exempt’ => ‘N’);

    $_discount = ($option == ‘Y’) ? fn_get_product_discount($product_id, $data, true, $_auth) : 0;

    return fn_format_price($data - $_discount);



    } else {

    return strip_tags(str_replace( array(‘
    ’,‘
    ’, ‘
    ’, ‘
    ’), “\n”, $data));

    }

    }



    //

    // Transfers export file to Google base servers

    // Parameters:

    // @filename - file name to transfer



    function fn_exim_transfer_google_file($filename)

    {

    global $current_location, $admin_index, $target_name, $var_dir;



    if (function_exists(‘ftp_connect’)) {

    $google_sets = fn_get_settings_section(‘Google’);

    $object = ‘google’;



    $_ftp_host = $google_sets[$object . ‘_host’];

    $ftp_login = $google_sets[$object . ‘_login’];

    $ftp_pass = $google_sets[$object . ‘_pass’];



    $__ftp_host = parse_url($_ftp_host);

    $ftp_host = empty($__ftp_host[‘host’]) ? $__ftp_host[‘path’] : $__ftp_host[‘host’];



    if (empty($ftp_host) || empty($ftp_login) || empty($ftp_pass)) {

    $_hl = ‘google_host,google_login,google_pass’;

    $_set = “Google base”;

    fn_set_notification(‘W’, fn_get_lang_var(‘warning’), str_replace(‘[settings]’, $_set, fn_get_lang_var(‘specify_ftp_parameters’)));

    return false;

    }



    $ftp = ftp_connect($ftp_host);

    if ($ftp && ftp_login($ftp, $ftp_login, $ftp_pass)) {

    ftp_pasv($ftp, true);

    $fp = fopen($var_dir[‘exim’] . $filename, “rb”);

    if ($fp) {

    echo “
    Copying file to the google server…”;

    fn_flush();

    if (@ftp_fput($ftp, basename($filename), $fp, FTP_BINARY)) {

    fn_set_notification(‘N’, fn_get_lang_var(‘notice’), fn_get_lang_var(‘file_succ_transfered’));

    } else {

    fn_set_notification(‘E’, fn_get_lang_var(‘error’), fn_get_lang_var(‘file_transfer_failed’));

    }

    fclose($fp);

    } else {

    fn_set_notification(‘E’, fn_get_lang_var(‘error’), fn_get_lang_var(‘file_not_found’));

    }



    ftp_quit($ftp);

    } else {

    fn_set_notification(‘E’, fn_get_lang_var(‘error’), str_replace(“[cscart_admin]”, $current_location .‘/’. $admin_index, fn_get_lang_var(‘ftp_connect_failed’)));

    }

    } else {

    fn_set_notification(‘E’, fn_get_lang_var(‘error’), fn_get_lang_var(‘php_do_not_support_ftp’));

    }



    return true;

    }



    function fn_exim_google_get_types()

    {

    return array (

    [COLOR=“blue”]‘Tools’ => ‘Tools’,

    ‘Other’ => ‘Other’,[/COLOR]

    ‘2-way radios’ => ‘2-way radios’,

    ‘accessories’ => ‘accessories’,



    );

    }



    [COLOR=“blue”]function fn_exim_google_get_conditions()

    {

    return array (

    ‘New’ => ‘New’,

    ‘Used’ => ‘Used’,

    ‘Refurbished’ => ‘Refurbished’,

    );

    }[/COLOR]



    ?> ```

    gb_prod_cond.jpg

I am using ver 1.3.5 sp3



I used the info you posted above to add stuff to the google export and I get this





Database error: 1054 : Unknown column ‘products.condition’ in ‘field list’

Invalid query: SELECT products.product_id, products.product_id as “id”, products.condition, products.amount as “quantity”, product_prices.price as “price”, products.product_code as “mpn”, product_descriptions.product as “title”, product_descriptions.full_description as “description”, product_images_links.image_id as “image_link” FROM cscart_products as products LEFT JOIN cscart_product_descriptions as product_descriptions ON product_descriptions.product_id = products.product_id AND product_descriptions.lang_code = ‘EN’ LEFT JOIN cscart_product_prices as product_prices ON product_prices.product_id = products.product_id AND product_prices.lower_limit = ‘1’ AND product_prices.membership_id = ‘0’ LEFT JOIN cscart_product_images_links as product_images_links ON product_images_links.product_id = products.product_id AND product_images_links.type = ‘M’ WHERE products.avail IN (‘Y’) LIMIT 0, 30



Backtrace:

File: /var/www/vhosts/evitaminworld.com/httpdocs/admin.php

Line: 79

Function: include

File: /var/www/vhosts/evitaminworld.com/httpdocs/targets/exim.php

Line: 35

Function: include

File: /var/www/vhosts/evitaminworld.com/httpdocs/include/admin/exim.php

Line: 110

Function: fn_export

File: /var/www/vhosts/evitaminworld.com/httpdocs/include/admin/exim.php

Line: 681

Function: db_get_array

File: /var/www/vhosts/evitaminworld.com/httpdocs/core/fn_database.php

Line: 42

Function: db_query

File: /var/www/vhosts/evitaminworld.com/httpdocs/core/db_mysql.php

Line: 94

Function: db_debug_error







Where did I go wrong?

Ok I figured out that I missed a section of the code, so I went over it again and again, now I am getting the following error:



Database error: 1054 : Unknown column ‘products.quantity’ in ‘field list’

Invalid query: SELECT products.product_id, products.product_id as “id”, products.quantity as “quantity”, product_prices.price as “price”, products.product_code as “mpn”, product_descriptions.product as “title”, product_descriptions.full_description as “description”, product_images_links.image_id as “image_link” FROM cscart_products as products LEFT JOIN cscart_product_descriptions as product_descriptions ON product_descriptions.product_id = products.product_id AND product_descriptions.lang_code = ‘EN’ LEFT JOIN cscart_product_prices as product_prices ON product_prices.product_id = products.product_id AND product_prices.lower_limit = ‘1’ AND product_prices.membership_id = ‘0’ LEFT JOIN cscart_product_images_links as product_images_links ON product_images_links.product_id = products.product_id AND product_images_links.type = ‘M’ WHERE products.avail IN (‘Y’) LIMIT 0, 30



Backtrace:

File: /var/www/vhosts/evitaminworld.com/httpdocs/admin.php

Line: 79

Function: include

File: /var/www/vhosts/evitaminworld.com/httpdocs/targets/exim.php

Line: 35

Function: include

File: /var/www/vhosts/evitaminworld.com/httpdocs/include/admin/exim.php

Line: 110

Function: fn_export

File: /var/www/vhosts/evitaminworld.com/httpdocs/include/admin/exim.php

Line: 681

Function: db_get_array

File: /var/www/vhosts/evitaminworld.com/httpdocs/core/fn_database.php

Line: 42

Function: db_query

File: /var/www/vhosts/evitaminworld.com/httpdocs/core/db_mysql.php

Line: 94

Function: db_debug_error



Any help is appreciated to get me back to track.



Thanks,

sraza

Thank you Tool Outfitters, It works perfect. Although you forgot to mention to add a language variable for product_condition.



Thank you for your contribution.

Well, I added in the variable for product_condition, still having issues.



also see attached, I am missing the text for it to be SEF (search engine friendly).



It was there before making mods, what gives?



none of the code changed seems to point to this as root cause, yet here I am.



Any one else able to assist me please?



thanks,

sraza

exports.gif

My bad I think sraza.? I don’t use “quantity” when exporting to Google but I changed it because it is used when exporting products normally. Change it back to “amount” and see if it fixes the error.



Report back so I can edit the post.



As for the SEF, I am not sure what went wrong. Look over it again and make sure.



Edit: Do not use the file that is posted because it is not complete. Only make the changes that are in [COLOR=“Blue”]BLUE[/COLOR].

Sorry, experienced a server crash and havent recovered yet fully.

Recovered now, went back in and attempted this again, mind you I am on 1.3.5 sp3 and havent upgraded yet.



I am experiencing some difficulties with this and am reporting back as you requested, please see if you can help me get this part back on track.



Thanks in advance, I really do appreciate all the help



<< see attached >>

still_issue.jpg

Hi sraza,



I’m not sure what the problem could be so I have attached my file.

exim[1].google.zip

Hi



Bit late for this one but just installed it, works great.



Many thanks:p :stuck_out_tongue:

Adding the google base product condition attribute to CS 2.x works just the same. Make the [COLOR=“Blue”]below changes[/COLOR] to: schemas/exim/google.php



Also don’t forget to add product_condition to language variables.





// $Id: google.php 7502 2009-05-19 14:54:59Z zeke $
//

if ( !defined('AREA') ) { die('Access denied'); }

//
// Schema definition
//
$schema = array (
'#section' => 'products',
'#key' => array('product_id'),
'#enclosure' => '',
'#name' => fn_get_lang_var('google_base'),
'#pattern_id' => 'google',
'#table' => 'products',
'#condition' => array('status' => 'A'),
'#export_only' => true,
'#range_options' => array (
'#selector_url' => INDEX_SCRIPT . '?dispatch=products.manage',
'#object_name' => fn_get_lang_var('products'),
),
'#references' => array (
'product_descriptions' => array (
'#reference_fields' => array ('product_id' => '#key', 'lang_code' => '@lang_code'),
'#join_type' => 'LEFT'
),
'product_prices' => array (
'#reference_fields' => array ('product_id' => '#key', 'lower_limit' => 1, 'membership_id' => 0),
'#join_type' => 'LEFT'
),
'images_links' => array (
'#reference_fields' => array('object_id' => '#key', 'object_type' => 'product', 'type' => 'M'),
'#join_type' => 'LEFT'
),
),
'#options' => array (
'lang_code' => array (
'title' => 'language',
'type' => 'languages'
),
'product_type' => array (
'title' => 'product_type',
'type' => 'select',
'variants_function' => 'fn_exim_google_get_types',
),
[COLOR="Blue"] 'condition' => array (
'title' => 'product_condition',
'type' => 'select',
'variants_function' => 'fn_exim_google_get_conditions',
),[/COLOR]
'discounts' => array (
'title' => 'export_discounts',
'type' => 'checkbox'
),
),
'#override_options' => array (
'delimiter' => 'T',
'output' => 'S',
),
'#post_processing' => array ('fn_exim_transfer_google_file', '@filename'),
'#export_fields' => array (
'id' => array (
'#db_field' => 'product_id',
'#required' => true,
'#alt_key' => true
),
'product_type' => array (
'#process_get' => array('fn_exim_google_format_field', '', 'product_type', '', '@product_type'),
'#linked' => false
),
[COLOR="Blue"] 'condition' => array (
'#process_get' => array('fn_exim_google_format_field', '', 'condition', '', '@condition'),
'#linked' => false
),[/COLOR]
'quantity' => array (
'#db_field' => 'amount'
),
[COLOR="Blue"]'weight' => array (
'#db_field' => 'weight'
),[/COLOR]
'price' => array (
'#table' => 'product_prices',
'#db_field' => 'price',
'#process_get' => array('fn_exim_google_format_field', '#this', 'price', '#key', '@discounts')
),
'mpn' => array (
'#db_field' => 'product_code'
),
'title' => array (
'#table' => 'product_descriptions',
'#db_field' => 'product',
'#process_get' => array('fn_exim_google_format_field', '#this', 'title'),
),
'description' => array (
'#table' => 'product_descriptions',
'#db_field' => 'full_description',
'#process_get' => array('fn_exim_google_format_field', '#this', 'description'),
),
'link' => array (
'#process_get' => array ('fn_exim_get_product_url', '#key'),
'#linked' => false
),
'image_link' => array (
'#process_get' => array ('fn_exim_get_image_url', '#this', 'product'),
'#db_field' => 'image_id',
'#table' => 'images_links',
),
// Please uncomment this code if you want to export ISBN feature to the google
/* 'ISBN' => array (
'#process_get' => array ('fn_exim_get_feature', '#key', 'ISBN'),
'#linked' => false
),*/
),
);


// ------------- Utility functions ---------------

//
// Get product url
// Parameters:
// @product_id - product ID

function fn_exim_get_product_url($product_id, $options = '')
{
$url = Registry::get('config.http_location') .'/'. Registry::get('config.customer_index') . "?dispatch=products&product_id=$product_id";

fn_set_hook('exim_get_product_url', $url, $product_id, $options);

return $url;
}

//
// This function get the feature value
function fn_exim_get_feature($product_id, $feature_name)
{
$feature = db_get_field("SELECT value FROM ?:product_features_values as a LEFT JOIN ?:product_features_descriptions as b ON a.feature_id = b.feature_id AND b.lang_code = ?s WHERE b.description = ?s AND a.product_id = ?i AND a.lang_code = ?s", CART_LANGUAGE, $feature_name, $product_id, CART_LANGUAGE);

return $feature;
}

//
// Formats field by its type
// Parameters:
// @data - field to be formatted
// @type - field type
function fn_exim_google_format_field($data, $type, $product_id = 0, $option = '')
{
if ($type == 'product') {
return substr(strip_tags($data), 0, 80);

} elseif ($type == 'product_type') {
return (!empty($option)) ? $option : 'other';

[COLOR="Blue"] } elseif ($type == 'condition') {
return (!empty($option)) ? $option : 'new';[/COLOR]

} elseif ($type == 'price') {
$_auth = array('user_id' => 0, 'membership_id' => 0, 'tax_exempt' => 'N');
$_discount = ($option == 'Y') ? fn_get_product_discount($product_id, $data, true, $_auth) : 0;
return fn_format_price($data - $_discount);

} else {
return strip_tags(str_replace( array('
','
', '
', '
'), "\\n", $data));
}
}

//
// Transfers export file to Google base servers
// Parameters:
// @filename - file name to transfer

function fn_exim_transfer_google_file($filename)
{
if (function_exists('ftp_connect')) {
$google_sets = fn_get_settings('Google');
$object = 'google';

$_ftp_host = $google_sets[$object . '_host'];
$ftp_login = $google_sets[$object . '_login'];
$ftp_pass = $google_sets[$object . '_pass'];

$__ftp_host = parse_url($_ftp_host);
$ftp_host = empty($__ftp_host['host']) ? $__ftp_host['path'] : $__ftp_host['host'];

if (empty($ftp_host) || empty($ftp_login) || empty($ftp_pass)) {
$_hl = 'google_host,google_login,google_pass';
$_set = "Google base";
fn_set_notification('W', fn_get_lang_var('warning'), str_replace('[settings]', $_set, fn_get_lang_var('specify_ftp_parameters')));
return false;
}

$ftp = @ftp_connect($ftp_host);
if ($ftp && @ftp_login($ftp, $ftp_login, $ftp_pass)) {
ftp_pasv($ftp, true);
$fp = fopen(DIR_EXIM . $filename, "rb");
if ($fp) {
echo "
Copying file to the google server...";
fn_flush();
if (@ftp_fput($ftp, basename($filename), $fp, FTP_BINARY)) {
fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('file_succ_transfered'));
} else {
fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('file_transfer_failed'));
return false;
}
fclose($fp);
} else {
fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('file_not_found'));

return false;
}

ftp_quit($ftp);
} else {
fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('ftp_connect_failed'));

return false;
}
} else {
fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('php_do_not_support_ftp'));

return false;
}

return true;
}

function fn_exim_google_get_types()
{
return array (
'tools' => 'tools',
'other' => 'other',
'2-way radios' => '2-way radios',
'accessories' => 'accessories',
'adapters' => 'adapters',
'adhesives' => 'adhesives',
'air compressors' => 'air compressors',
'air conditioners' => 'air conditioners',
'air coolers' => 'air coolers',
'air purifiers' => 'air purifiers',
'airsoft' => 'airsoft',
'alarms' => 'alarms',
'am/fm radios' => 'am/fm radios',
'amplifiers' => 'amplifiers',
'analyzers' => 'analyzers',
'antennas' => 'antennas',
'antiques' => 'antiques',
'appliances' => 'appliances',
);
}

[COLOR="Blue"]function fn_exim_google_get_conditions()
{
return array (
'new' => 'new',
'used' => 'used',
'refurbished' => 'refurbished',
);
}[/COLOR]

?>

Can anyone show me how/where to do this (add product condition) for 1.3.5 SP2?



Thanks

It should be the same as described in post #2.

[quote name=‘Tool Outfitters’]It should be the same as described in post #2.[/QUOTE]



I can’t seem to find the file. On my version the closest path to what you indicate is;



/skins/default_blue/admin/exim_pages



but then there is no file that corresponds to the exim.google.php file, only tpl files and nothing that contains the google attributes.

Is there a way to access the root directory through the backdoor on SP2, or does this have to be done from outside of the cs-cart admin?

[quote name=‘CNutrition’]I can’t seem to find the file. On my version the closest path to what you indicate is;



/skins/default_blue/admin/exim_pages



but then there is no file that corresponds to the exim.google.php file, only tpl files and nothing that contains the google attributes.[/QUOTE]

The file is located at /include/admin/exim/exim.google.php. Are you saying you do not have the /include directory in the root directory?



Bob

[quote name=‘CNutrition’]Is there a way to access the root directory through the backdoor on SP2, or does this have to be done from outside of the cs-cart admin?[/QUOTE]



No. Only the template files are available from the admin section. You must access the files on your server to make the changes.

Thanks Tool Outfitters. I’m running 1.3.5 SP4 and it worked like a charm. I changed the two instances of “Other” to be “Refurbished” instead so it would match Google’s latest attributes.

This does not work for me with 2.04 ?



After adding 4 parts in blue when I enter

admin.php?dispatch=exim.export



page goes blank.



Should product_condition should be with empty value?


[quote name=‘Tool Outfitters’]Adding the google base product condition attribute to CS 2.x works just the same. Make the [COLOR=“Blue”]below changes[/COLOR] to: schemas/exim/google.php



Also don’t forget to add product_condition to language variables.





// $Id: google.php 7502 2009-05-19 14:54:59Z zeke $
//

if ( !defined('AREA') ) { die('Access denied'); }

//
// Schema definition
//
$schema = array (
'#section' => 'products',
'#key' => array('product_id'),
'#enclosure' => '',
'#name' => fn_get_lang_var('google_base'),
'#pattern_id' => 'google',
'#table' => 'products',
'#condition' => array('status' => 'A'),
'#export_only' => true,
'#range_options' => array (
'#selector_url' => INDEX_SCRIPT . '?dispatch=products.manage',
'#object_name' => fn_get_lang_var('products'),
),
'#references' => array (
'product_descriptions' => array (
'#reference_fields' => array ('product_id' => '#key', 'lang_code' => '@lang_code'),
'#join_type' => 'LEFT'
),
'product_prices' => array (
'#reference_fields' => array ('product_id' => '#key', 'lower_limit' => 1, 'membership_id' => 0),
'#join_type' => 'LEFT'
),
'images_links' => array (
'#reference_fields' => array('object_id' => '#key', 'object_type' => 'product', 'type' => 'M'),
'#join_type' => 'LEFT'
),
),
'#options' => array (
'lang_code' => array (
'title' => 'language',
'type' => 'languages'
),
'product_type' => array (
'title' => 'product_type',
'type' => 'select',
'variants_function' => 'fn_exim_google_get_types',
),
[COLOR="Blue"] 'condition' => array (
'title' => 'product_condition',
'type' => 'select',
'variants_function' => 'fn_exim_google_get_conditions',
),[/COLOR]
'discounts' => array (
'title' => 'export_discounts',
'type' => 'checkbox'
),
),
'#override_options' => array (
'delimiter' => 'T',
'output' => 'S',
),
'#post_processing' => array ('fn_exim_transfer_google_file', '@filename'),
'#export_fields' => array (
'id' => array (
'#db_field' => 'product_id',
'#required' => true,
'#alt_key' => true
),
'product_type' => array (
'#process_get' => array('fn_exim_google_format_field', '', 'product_type', '', '@product_type'),
'#linked' => false
),
[COLOR="Blue"] 'condition' => array (
'#process_get' => array('fn_exim_google_format_field', '', 'condition', '', '@condition'),
'#linked' => false
),[/COLOR]
'quantity' => array (
'#db_field' => 'amount'
),
'price' => array (
'#table' => 'product_prices',
'#db_field' => 'price',
'#process_get' => array('fn_exim_google_format_field', '#this', 'price', '#key', '@discounts')
),
'mpn' => array (
'#db_field' => 'product_code'
),
'title' => array (
'#table' => 'product_descriptions',
'#db_field' => 'product',
'#process_get' => array('fn_exim_google_format_field', '#this', 'title'),
),
'description' => array (
'#table' => 'product_descriptions',
'#db_field' => 'full_description',
'#process_get' => array('fn_exim_google_format_field', '#this', 'description'),
),
'link' => array (
'#process_get' => array ('fn_exim_get_product_url', '#key'),
'#linked' => false
),
'image_link' => array (
'#process_get' => array ('fn_exim_get_image_url', '#this', 'product'),
'#db_field' => 'image_id',
'#table' => 'images_links',
),
// Please uncomment this code if you want to export ISBN feature to the google
/* 'ISBN' => array (
'#process_get' => array ('fn_exim_get_feature', '#key', 'ISBN'),
'#linked' => false
),*/
),
);


// ------------- Utility functions ---------------

//
// Get product url
// Parameters:
// @product_id - product ID

function fn_exim_get_product_url($product_id, $options = '')
{
$url = Registry::get('config.http_location') .'/'. Registry::get('config.customer_index') . "?dispatch=products&product_id=$product_id";

fn_set_hook('exim_get_product_url', $url, $product_id, $options);

return $url;
}

//
// This function get the feature value
function fn_exim_get_feature($product_id, $feature_name)
{
$feature = db_get_field("SELECT value FROM ?:product_features_values as a LEFT JOIN ?:product_features_descriptions as b ON a.feature_id = b.feature_id AND b.lang_code = ?s WHERE b.description = ?s AND a.product_id = ?i AND a.lang_code = ?s", CART_LANGUAGE, $feature_name, $product_id, CART_LANGUAGE);

return $feature;
}

//
// Formats field by its type
// Parameters:
// @data - field to be formatted
// @type - field type
function fn_exim_google_format_field($data, $type, $product_id = 0, $option = '')
{
if ($type == 'product') {
return substr(strip_tags($data), 0, 80);

} elseif ($type == 'product_type') {
return (!empty($option)) ? $option : 'other';

[COLOR="Blue"] } elseif ($type == 'condition') {
return (!empty($option)) ? $option : 'new';[/COLOR]

} elseif ($type == 'price') {
$_auth = array('user_id' => 0, 'membership_id' => 0, 'tax_exempt' => 'N');
$_discount = ($option == 'Y') ? fn_get_product_discount($product_id, $data, true, $_auth) : 0;
return fn_format_price($data - $_discount);

} else {
return strip_tags(str_replace( array('
','
', '
', '
'), "\\n", $data));
}
}

//
// Transfers export file to Google base servers
// Parameters:
// @filename - file name to transfer

function fn_exim_transfer_google_file($filename)
{
if (function_exists('ftp_connect')) {
$google_sets = fn_get_settings('Google');
$object = 'google';

$_ftp_host = $google_sets[$object . '_host'];
$ftp_login = $google_sets[$object . '_login'];
$ftp_pass = $google_sets[$object . '_pass'];

$__ftp_host = parse_url($_ftp_host);
$ftp_host = empty($__ftp_host['host']) ? $__ftp_host['path'] : $__ftp_host['host'];

if (empty($ftp_host) || empty($ftp_login) || empty($ftp_pass)) {
$_hl = 'google_host,google_login,google_pass';
$_set = "Google base";
fn_set_notification('W', fn_get_lang_var('warning'), str_replace('[settings]', $_set, fn_get_lang_var('specify_ftp_parameters')));
return false;
}

$ftp = @ftp_connect($ftp_host);
if ($ftp && @ftp_login($ftp, $ftp_login, $ftp_pass)) {
ftp_pasv($ftp, true);
$fp = fopen(DIR_EXIM . $filename, "rb");
if ($fp) {
echo "
Copying file to the google server...";
fn_flush();
if (@ftp_fput($ftp, basename($filename), $fp, FTP_BINARY)) {
fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('file_succ_transfered'));
} else {
fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('file_transfer_failed'));
return false;
}
fclose($fp);
} else {
fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('file_not_found'));

return false;
}

ftp_quit($ftp);
} else {
fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('ftp_connect_failed'));

return false;
}
} else {
fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('php_do_not_support_ftp'));

return false;
}

return true;
}

function fn_exim_google_get_types()
{
return array (
'tools' => 'tools',
'other' => 'other',
'2-way radios' => '2-way radios',
'accessories' => 'accessories',
'adapters' => 'adapters',
'adhesives' => 'adhesives',
'air compressors' => 'air compressors',
'air conditioners' => 'air conditioners',
'air coolers' => 'air coolers',
'air purifiers' => 'air purifiers',
'airsoft' => 'airsoft',
'alarms' => 'alarms',
'am/fm radios' => 'am/fm radios',
'amplifiers' => 'amplifiers',
'analyzers' => 'analyzers',
'antennas' => 'antennas',
'antiques' => 'antiques',
'appliances' => 'appliances',
);
}

[COLOR="Blue"]function fn_exim_google_get_conditions()
{
return array (
'new' => 'new',
'used' => 'used',
'refurbished' => 'refurbished',
);
}[/COLOR]

?>
[/QUOTE]