This one took me a while to figure out (I even went as far as asking for a quote to add it) but I finally figured it out. I was hitting all around it but I had a few minor mistakes here and there that I finally corrected.
The main purpose of this is to export Manufacurers/brand to Google Base but it can also be used for other product feature variants by changing the name in the export option to your feature. I haven’t tried it but the same goes for the feature value already in the code. The changes I have made are in [COLOR=“Blue”]blue[/COLOR] and I also added “value” to the original function so that it is not confused with the “variant” function.
/schemas/exim/google.php
[COLOR="Blue"]'brand' => array (
'#process_get' => array ('fn_exim_get_feature_variant', '#key', 'Manufacturer'),
'#linked' => false
),[/COLOR]
// Please uncomment this code if you want to export ISBN feature to the google
/* 'ISBN' => array (
'#process_get' => array ('fn_exim_get_feature[COLOR="Blue"]_value[/COLOR]', '#key', 'ISBN'),
'#linked' => false
),*/
),
);
// ------------- Utility functions ---------------
//
// This function get the feature value
function fn_exim_get_feature[COLOR="Blue"]_value[/COLOR]($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;
}
[COLOR="Blue"]//
// This function gets the feature variant
function fn_exim_get_feature_variant($product_id, $feature_name)
{
$feature = db_get_field("SELECT variant FROM ?:product_feature_variant_descriptions AS a INNER JOIN cscart_product_features_values AS b ON a.variant_id = b.variant_id INNER JOIN cscart_product_features_descriptions AS c ON b.feature_id = c.feature_id AND b.lang_code= ?s WHERE c.description = ?s AND b.product_id = ?i AND a.lang_code = ?s", CART_LANGUAGE, $feature_name, $product_id, CART_LANGUAGE);
return $feature;
}[/COLOR]