I've been trying to get a manufacturer logo in both browse page and detailed product page for long time until y got the clue, thanks to guilliam (he did most of the work), in this post
http://forum.virtuemart.net/index.php?topic=48371.msg256366#msg256366since i dont use 'manufacturer description' for any purpose i'm using it to store the manufacturer logo.
So first of all we have to include our manufacturer logo in manufacturer description, we should upload a small logo, lets say 22 px height and 100 px width.
for the logo to be SEO friendly i recomend to save the logos using a code like this
<img title="adidas" alt="adidas" src="images/brands/adidas.gif" height="22" width="110" />
BROWSE PAGEwe have to modify the following files
\administrator\components\com_virtuemart\html\shop_browse_queries.php
around line 37 change the line:
$fieldnames = "`#__{vm}_product`.`product_id`, `product_name`, `products_per_row`, `category_browsepage`, `category_flypage`, `#__{vm}_category`.`category_id`, `product_full_image`, `product_thumb_image`, `product_s_desc`, `product_parent_id`, `product_publish`, `product_in_stock`, `product_sku`, `product_url`, `product_weight`, `product_weight_uom`, `product_length`, `product_width`, `product_height`, `product_lwh_uom`, `product_available_date`, `product_availability`, `#__{vm}_product`.`mdate`, `#__{vm}_product`.`cdate`";
for these ones:
$fieldnames = "`#__{vm}_product`.`product_id`, `product_name`, `products_per_row`, `category_browsepage`, `category_flypage`, `#__{vm}_category`.`category_id`, `product_full_image`, `product_thumb_image`, `product_s_desc`, `product_parent_id`, `product_publish`, `product_in_stock`, `product_sku`, `product_url`, `product_weight`, `product_weight_uom`, `product_length`, `product_width`, `product_height`, `product_lwh_uom`, `product_available_date`, `product_availability`, `#__{vm}_product`.`mdate`, `#__{vm}_product`.`cdate`,`#__{vm}_manufacturer`.`manufacturer_id`,`#__{vm}_manufacturer`.`mf_name`,`#__{vm}_manufacturer`.`mf_desc`";
// add manufacturer logo hack - we have added `#__{vm}_manufacturer`.`manufacturer_id`,`#__{vm}_manufacturer`.`mf_name`,`#__{vm}_manufacturer`.`mf_desc`
around line 170 change:
// GET ALL PUBLISHED PRODUCTS FROM THAT MANUFACTURER
if (!empty($manufacturer_id)) {
$table_names .= ',`#__{vm}_product_mf_xref`';
$where_clause[] = "manufacturer_id='".$manufacturer_id."'";
$where_clause[] = "`#__{vm}_product`.`product_id`=`#__{vm}_product_mf_xref`.`product_id` ";
}
for this ones:
// GET ALL PUBLISHED PRODUCTS FROM THAT MANUFACTURER
if (!empty($manufacturer_id)) {
// $table_names .= ',`#__{vm}_product_mf_xref`';
$where_clause[] = "`#__{vm}_manufacturer`.`manufacturer_id`='".$manufacturer_id."'";
// $where_clause[] = "`#__{vm}_product`.`product_id`=`#__{vm}_product_mf_xref`.`product_id` ";
}
around line 315 just after this lines:
else {
$where_clause[] = "((`#__{vm}_product`.`product_id`=`#__{vm}_product_price`.`product_id` AND `#__{vm}_shopper_group`.`shopper_group_id`=`#__{vm}_product_price`.`shopper_group_id`) OR `#__{vm}_product_price`.`product_id` IS NULL) ";
$where_clause[] = '`#__{vm}_shopper_group`.`default` = 1';
}
add:
// add manufacturer logo hack
$join_array[] = 'LEFT JOIN `#__{vm}_product_mf_xref` ON `#__{vm}_product_mf_xref`.`product_id` = `#__{vm}_product`.`product_id`';
$join_array[] = 'LEFT JOIN `#__{vm}_manufacturer` ON `#__{vm}_manufacturer`.`manufacturer_id` = `#__{vm}_product_mf_xref`.`manufacturer_id`';
// hack ends
\administrator\components\com_virtuemart\html\shop.browse.php
around line 463, after:
$products[$i]['product_url'] = $db_browse->f("product_url");
add:
$products[$i]['manufacturer_name'] = $db_browse->f("mf_name");
$products[$i]['manufacturer_desc'] = $db_browse->f("mf_desc");
with this we are ready to show the manufacturer logo in browse page including this in the template browse1.php or the one we are using
<?php echo $manufacturer_desc ?>
--------------------------
FLYPAGEto get the logo shown in the flypage we have modify the following files:
administrator/components/com_virtuemart/classes/ps_product.php
around line 1307 just BEFORE:
/**
* This function retrieves the "neighbor" products of a product specified by $product_idi
add:
/** add manufacturer logo hack
* Functon to get the 'manufacturer description' -logo- this product is assigned to
*
* @param int $product_id
* @return string the manufacturer name
*/
function get_mf_desc($product_id) {
$db = new ps_DB;
$q = "SELECT mf_desc,#__{vm}_manufacturer.manufacturer_id FROM #__{vm}_product_mf_xref,#__{vm}_manufacturer ";
$q .= "WHERE product_id='$product_id' ";
$q .= "AND #__{vm}_manufacturer.manufacturer_id=#__{vm}_product_mf_xref.manufacturer_id";
$db->query($q);
$db->next_record();
if ($db->f("mf_desc")) {
return $db->f("mf_desc");
}
else {
return "";
}
}
/** hack ends */
administrator/components/com_virtuemart/html/shop.product_details.php
around 34, after:
require_once(CLASSPATH . 'ps_reviews.php' );
add:
// add manufacturer logo hack
require_once(CLASSPATH . 'ps_manufacturer.php' );
// hack ends
around line 266, after:
$manufacturer_name = $ps_product->get_mf_name($product_id);
add:
// add manufacturer logo hack
$manufacturer_desc = $ps_product->get_mf_desc($product_id);
// hack ends
around line 438, after:
$tpl->set( "product_description", $product_description );
add:
// add manufacturer logo hack
$tpl->set( "manufacturer_desc", $manufacturer_desc );
// hack ends
then we have to modify the flypage file
/components/com_virtuemart/themes/default/templates/product_details/flypage.tpl.php
add this code where we want the logo to be shown
<?php echo $manufacturer_desc ?>
Updated and working with J 1.5.22 and VM 1.1.8