VirtueMart Dev/Coding Central: VM1 (old version) > Development Projects, Modifications, Hacks & Tweaks. VM1.1

Add manufacturer logo in browse & flypage

(1/4) > >>

ruben-sp:
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#msg256366

since 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 PAGE
we have to modify the following files
 \administrator\components\com_virtuemart\html\shop_browse_queries.php
around line 37 change the line:

--- Code: ---$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`";

--- End code ---
for these ones:

--- Code: ---$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`

--- End code ---
around line 170 change:

--- Code: ---// 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` ";

}

--- End code ---


for this ones:


--- Code: ---// 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` ";

}


--- End code ---


around line 315 just after this lines:

--- Code: ---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';
}

--- End code ---
add:

--- Code: ---// 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

--- End code ---

 \administrator\components\com_virtuemart\html\shop.browse.php
around line 463, after:

--- Code: --- $products[$i]['product_url'] = $db_browse->f("product_url");

--- End code ---
add:

--- Code: --- $products[$i]['manufacturer_name'] = $db_browse->f("mf_name");
$products[$i]['manufacturer_desc'] = $db_browse->f("mf_desc");

--- End code ---
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

--- Code: ---<?php echo $manufacturer_desc ?>

--- End code ---
--------------------------

FLYPAGE
to 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:

--- Code: --- /** 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 */

--- End code ---

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

marxam:
Hi Dude!

I tried your hack but it didn't work for some reason.

I am using VM 1.1.5 and Joomla 1.5.22

It simply displayed the page without the manufacturer name AND manufacturer logo.

Any suggestions?

WaoX:
Excelent! Works very vell. Joomla 1.5.22 and Virtuemart 1.1.5

Thankyou!

bobby_38:
yep very good i make a hack was working but always show the same logo :(

now is work with this one is screaming....thank a lot!!!!

http://204.232.208.203/memory-and-media/view-all-products.html

yay....got issue in my manufacturer page when i got many categories just show one...dunno why

anne19:
Hey, thanks! Works well. Wish I had found this earlier though lol, been looking for something similar for a while now, do you know if there's any newer versions? I'm not sure it will be compatible with the newer version I've got.. I guess I'll keep looking around on the forums..


--- Quote from: ruben-sp on November 02, 2010, 09:01:10 AM ---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#msg256366

since i dont use 'manufacturer description' for any purpose i'm using it to store the manufacturer logo.

Attached are screenshots

So first of all we have to include our manufacturer logo in manufacturer description, we should upload a small logo, lets say 20/30 px height and 80/150 px width.

BROWSE PAGE
in \administrator\components\com_virtuemart\html\
we have to overwrite the files (attached are the modified ones)
shop_browse_queries.php and
shop.browse.php
as guilliam did in the mentioned post and modified to add the logo

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 ?>klonopin side effects
--------------------------

FLYPAGE
to get the logo in the flypage we have include the following lines:

administrator/components/com_virtuemart/classes/ps_product.php

in line 1278, where the   ''Functon to get the name of the manufacturer this product is assigned to ''     finishes
add:
   /** added by Ruben-sp....................................
    * Functon to get the 'manufacturer description' -picture- 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 "";
      }
   }

administrator/components/com_virtuemart/html/shop.product_details.php

in line 34, after require_once(CLASSPATH . 'ps_reviews.php' );
include:
require_once(CLASSPATH . 'ps_manufacturer.php' );

in line 259, after $manufacturer_name = $ps_product->get_mf_name($product_id);
include:
$manufacturer_desc = $ps_product->get_mf_desc($product_id);

in line 428, after $tpl->set( "product_description", $product_description );
include:
$tpl->set( "manufacturer_desc", $manufacturer_desc );

then we have to modify the flypage file by including where we want the logo to be shown.

i include the modified files for the ones dont want to type.


hope this hack is helpful for someone

--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version