Author Topic: Add manufacturer logo in browse & flypage  (Read 12594 times)

ruben-sp

  • Jr. Member
  • **
  • Posts: 64
Add manufacturer logo in browse & flypage
« on: November 02, 2010, 16:01:10 pm »
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: [Select]
$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:
Code: [Select]
$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:
Code: [Select]
// 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:

Code: [Select]
// 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:
Code: [Select]
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:
Code: [Select]
// 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:
Code: [Select]
$products[$i]['product_url'] = $db_browse->f("product_url");
add:
Code: [Select]
$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
Code: [Select]
<?php echo $manufacturer_desc ?>
--------------------------

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: [Select]
/** 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


marxam

  • Beginner
  • *
  • Posts: 2
Re: Add manufacturer logo in browse & flypage
« Reply #1 on: December 01, 2010, 16:28:26 pm »
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

  • Beginner
  • *
  • Posts: 8
Re: Add manufacturer logo in browse & flypage
« Reply #2 on: December 20, 2010, 11:17:34 am »
Excelent! Works very vell. Joomla 1.5.22 and Virtuemart 1.1.5

Thankyou!

bobby_38

  • Beginner
  • *
  • Posts: 19
    • Best IT store
Re: Add manufacturer logo in browse & flypage
« Reply #3 on: April 13, 2011, 06:08:39 am »
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
Try harder, one error today is the success of tomorrow

http://www.tech2cool.com

anne19

  • Beginner
  • *
  • Posts: 1
Re: Add manufacturer logo in browse & flypage
« Reply #4 on: August 04, 2011, 05:48:33 am »
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..

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

ruben-sp

  • Jr. Member
  • **
  • Posts: 64
Re: Add manufacturer logo in browse & flypage
« Reply #5 on: August 04, 2011, 08:41:39 am »
Quote
I'm not sure it will be compatible with the newer version I've got.

i havent tried it yet but i'll do in a couple of weeks as im working in a new project and im suppose to include logos manufacturer in every product.

ruben-sp

  • Jr. Member
  • **
  • Posts: 64
Re: Add manufacturer logo in browse & flypage
« Reply #6 on: September 03, 2011, 00:44:36 am »
Updated and working with J 1.5.22 and VM 1.1.8

FilipeRuivo

  • Jr. Member
  • **
  • Posts: 62
Re: Add manufacturer logo in browse & flypage
« Reply #7 on: December 17, 2011, 06:40:11 am »
Here is a simple way to do it, no need to edit all this files.

In the administrator/components/com_virtuemart/html/shop.browse.php
find
Code: [Select]
// i is the index for the array holding all products, we need to show. to allow sorting by discounted price,
// we need to use the price as first part of the index name!
$i = $product_price_raw['product_price'] . '_' . ++$counter;

add after around line 328
Code: [Select]
$products[$i]['product_id'] = $db_browse->f('product_id'); // add $product_id to browse page      



In the /components/com_virtuemart/themes/yourtemplate/theme.php add this right after // Your code here please...

Code: [Select]
function get_mdetails($product_id, $var) {
$db = new ps_DB;

$q = "SELECT * 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();
$html = $db->f($var);
return $html;
}

Now you can get the manufacturer details any here in your template

just type:

echo $this->get_mdetails( $product_id, 'manufacturer_id' );
echo $this->get_mdetails( $product_id, 'mf_name' );
echo $this->get_mdetails( $product_id, 'mf_desc' );
echo $this->get_mdetails( $product_id, 'mf_email' );
echo $this->get_mdetails( $product_id, 'mf_url' );


That's it ;)

ruben-sp

  • Jr. Member
  • **
  • Posts: 64
Re: Add manufacturer logo in browse & flypage
« Reply #8 on: December 17, 2011, 22:36:28 pm »
Here is a simple way to do it, no need to edit all this files and no core hack.

In the /components/com_virtuemart/themes/yourtemplate/theme.php add this right after // Your code here please...

Code: [Select]
function get_mdetails($product_id, $var) {
$db = new ps_DB;

$q = "SELECT * 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();
$html = $db->f($var);
return $html;
}

Now you can get the manufacturer details any here in your template

just type:

echo $this->get_mdetails( $product_id, 'manufacturer_id' );
echo $this->get_mdetails( $product_id, 'mf_name' );
echo $this->get_mdetails( $product_id, 'mf_desc' );
echo $this->get_mdetails( $product_id, 'mf_email' );
echo $this->get_mdetails( $product_id, 'mf_url' );


That's it ;)

thanks for your contribution! that's a very easy wat to get it.  it works fine for flypage but  unfortunately it does not work for browse pages :(, it shows all products with the information regarded to the last product's manufacturer

FilipeRuivo

  • Jr. Member
  • **
  • Posts: 62
Re: Add manufacturer logo in browse & flypage
« Reply #9 on: December 18, 2011, 16:43:59 pm »
Here is a simple way to do it, no need to edit all this files and no core hack.

In the /components/com_virtuemart/themes/yourtemplate/theme.php add this right after // Your code here please...

Code: [Select]
function get_mdetails($product_id, $var) {
$db = new ps_DB;

$q = "SELECT * 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();
$html = $db->f($var);
return $html;
}

Now you can get the manufacturer details any here in your template

just type:

echo $this->get_mdetails( $product_id, 'manufacturer_id' );
echo $this->get_mdetails( $product_id, 'mf_name' );
echo $this->get_mdetails( $product_id, 'mf_desc' );
echo $this->get_mdetails( $product_id, 'mf_email' );
echo $this->get_mdetails( $product_id, 'mf_url' );


That's it ;)

thanks for your contribution! that's a very easy wat to get it.  it works fine for flypage but  unfortunately it does not work for browse pages :(, it shows all products with the information regarded to the last product's manufacturer


My bad I forget to add a product_id into the browse page.

I have already corrected my solution in the previous post

LuisSkillis

  • Beginner
  • *
  • Posts: 3
Re: Add manufacturer logo in browse & flypage
« Reply #10 on: January 29, 2012, 10:27:56 am »
Here is a simple way to do it, no need to edit all this files.

In the administrator/components/com_virtuemart/html/shop.browse.php
find
Code: [Select]
// i is the index for the array holding all products, we need to show. to allow sorting by discounted price,
// we need to use the price as first part of the index name!
$i = $product_price_raw['product_price'] . '_' . ++$counter;

add after around line 328
Code: [Select]
$products[$i]['product_id'] = $db_browse->f('product_id'); // add $product_id to browse page      



In the /components/com_virtuemart/themes/yourtemplate/theme.php add this right after // Your code here please...

Code: [Select]
function get_mdetails($product_id, $var) {
$db = new ps_DB;

$q = "SELECT * 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();
$html = $db->f($var);
return $html;
}

Now you can get the manufacturer details any here in your template

just type:

echo $this->get_mdetails( $product_id, 'manufacturer_id' );
echo $this->get_mdetails( $product_id, 'mf_name' );
echo $this->get_mdetails( $product_id, 'mf_desc' );
echo $this->get_mdetails( $product_id, 'mf_email' );
echo $this->get_mdetails( $product_id, 'mf_url' );


That's it ;)
      
It works nice =P

now i want to put the logo on the featured page to...
I allready edit the templates/common/featuredproducts.tpl but with this -> echo $this->get_mdetails( $product_id, 'mf_desc' ); it dont show anything =/
need some help please

FilipeRuivo

  • Jr. Member
  • **
  • Posts: 62
Re: Add manufacturer logo in browse & flypage
« Reply #11 on: January 30, 2012, 22:05:42 pm »
Easy just use
$featured['product_id'] instead of $product_id like this
Code: [Select]
echo $this->get_mdetails( $featured['product_id'], 'mf_desc' );

LuisSkillis

  • Beginner
  • *
  • Posts: 3
Re: Add manufacturer logo in browse & flypage
« Reply #12 on: January 31, 2012, 08:49:08 am »
Easy just use
$featured['product_id'] instead of $product_id like this
Code: [Select]
echo $this->get_mdetails( $featured['product_id'], 'mf_desc' );


THANKS :D

FilipeRuivo

  • Jr. Member
  • **
  • Posts: 62
Re: Add manufacturer logo in browse & flypage
« Reply #13 on: January 31, 2012, 11:41:41 am »
Nice  8)
Any other question, don't hesitate to ask.

nesomis

  • Beginner
  • *
  • Posts: 6
Re: Add manufacturer logo in browse & flypage
« Reply #14 on: February 16, 2012, 15:13:57 pm »
Thanks to all. It works fine.

My question is how to add manufacturer thumb from resized folder?

thanks

VirtueMart Forum

Re: Add manufacturer logo in browse & flypage
« Reply #14 on: February 16, 2012, 15:13:57 pm »