Add Manufacturer/Brand To Google Base Export

I mentioned that I had created this mod in another post but I think it was imbedded in my Bing Shopping Export mod so I thought I would create this post for it.



Basically I just had to create a new function (was not easy figuring out the db query) and also a new array for Brand. Also, you can see in the below example where I have added UPC.



Note: Where you see “Manufacturer”, this is what you have named the feature so if your feature is named “Brand”, you will need to change it.



/schemas/exim/google.php


		[COLOR="Blue"]'brand' => array (<br />
			'process_get' => array ('fn_exim_get_feature_variant', '#key', 'Manufacturer'),<br />
			'linked' => false<br />
		),[/COLOR]<br />
// Please uncomment this code if you want to export ISBN feature to the google<br />
/*		'ISBN' => array (<br />
			'process_get' => array ('fn_exim_get_feature', '#key', 'ISBN'),<br />
			'linked' => false<br />
		),*/<br />
		'upc' => array (<br />
			'process_get' => array ('fn_exim_get_feature', '#key', 'UPC'),<br />
			'linked' => false<br />
		),<br />
	),<br />
);<br />
<br />
<br />
// ------------- Utility functions ---------------<br />
<br />
//<br />
// This function get the feature value<br />
function fn_exim_get_feature($product_id, $feature_name)<br />
{<br />
	$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);<br />
<br />
	return $feature;<br />
}<br />
<br />
[COLOR="Blue"]//<br />
// This function gets the feature variant<br />
function fn_exim_get_feature_variant($product_id, $feature_name)<br />
{<br />
	$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);<br />
<br />
	return $feature;<br />
}[/COLOR]

Thank you :slight_smile:

I use the Category to store my brand so I modified the above code to reflect that. Below are my changes, if someone needs it.



[COLOR="Blue"]'brand' => array (
'process_get' => array ('fn_exim_get_category', '#key'),
'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', '#key', 'ISBN'),
'linked' => false
),*/
),
);


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

//
// 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;
}
[COLOR="Blue"]// This function get the category(brand) value
function fn_exim_get_category($product_id)
{
$category = db_get_field("SELECT cd.category FROM ?:category_descriptions as cd INNER JOIN ?:products_categories pc on pc.category_id = cd.category_id WHERE pc.product_id = ?i", $product_id);

return $category;
}[/COLOR]