Google Base Product Feature Variants (Manufacturer) Export

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]

Well, I might have spoken too soon. This works on my server with MySql 4.1 but not on my other with 5.0.

All I can say is that it’s a damn good thing I don’t do this for a living…I would probably completely lose my ass! I even asked Scott to take a look at the code to see what was wrong and he was a little overwhelmed by the query and didn’t have the time to look into it.



Anyway, the code now works on both of my servers so feel free to try it and let us know how it is working for you.



Edit: I haven’t heard back from CSC but I am curious how much they are going to quote for this.?:smiley: