Author Topic: [Solved] Manufacturer Logo in Product Module  (Read 3106 times)

Geppux

  • Jr. Member
  • **
  • Posts: 173
[Solved] Manufacturer Logo in Product Module
« on: February 22, 2016, 18:12:33 pm »
Hi,
I would like to show the logo of the manufacturer in the product module... I already done for the product details page inserting in templates/my-template/html/com_virtuemart/productdetails/default.php the following code:
Code: [Select]
<?php
// Manufacturer of the Product
if (VmConfig::get('show_manufacturers'1) && !empty($this->product->virtuemart_manufacturer_id)) {
echo $this->loadTemplate('manufacturer');
}
?>
and in components/com_virtuemart/views/productdetails/tmpl/default_manufacturer.php the following code:
Code: [Select]
<div class="manufacturer">
<?php
$i 1;

$mans = array();
// Gebe die Hersteller aus
foreach($this->product->manufacturers as $manufacturers_details) {
//Link to products
$link JRoute::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id=' $manufacturers_details->virtuemart_manufacturer_id'&tmpl=component'FALSE);
$name $manufacturers_details->mf_name;
        
$image $manufacturers_details->images[0];
// Avoid JavaScript on PDF Output
if (!$this->writeJs) {
$mans[] = JHtml::_('link'$link$name);
} else {
$mans[] = '<a class="manuModal" rel="{handler: \'iframe\', size: {x: 700, y: 850}}" href="'.$link .'">'.$image->displayMediaThumb("",false).'</a>';
}
}
echo implode(', ',$mans);
?>

</div>

I tried to do the same for the product module but without success, there is someone that can help me?
Thank you, bye.

Giuseppe

VM 3.0.12
J 3.4.8

Geppux

  • Jr. Member
  • **
  • Posts: 173
Re: Manufacturer Logo in Product Module
« Reply #1 on: February 23, 2016, 10:57:24 am »
Following this post: http://forum.virtuemart.net/index.php?topic=128546.0 I tried to solve my problem renaming the image of one manufacturer with the same name of the manufacturer and inserting into template/my-template/html/mod_virtuemart_product/default.php this code:
Code: [Select]
<img src="images/<?php echo $product->mf_name ?>.png">But no success... any Idea???
Giuseppe

Ghost

  • Jr. Member
  • **
  • Posts: 419
Re: Manufacturer Logo in Product Module
« Reply #2 on: February 23, 2016, 12:17:47 pm »
Add images:
Code: [Select]
$mf = VmModel::getModel('Manufacturer');
$manufacturer = $mf->getManufacturer($product->virtuemart_manufacturer_id[0]);
$mf->addImages($manufacturer);
Call them like this:
Code: [Select]
echo $manufacturer->images[0]->displayMediaThumb('',false);
Or if you just need image URL:

Code: [Select]
$manufacturer->images[0]->file_url; //full image
$manufacturer->images[0]->file_url_thumb; // thumbnail

Geppux

  • Jr. Member
  • **
  • Posts: 173
Re: Manufacturer Logo in Product Module
« Reply #3 on: February 23, 2016, 12:33:01 pm »
Thank you Ghost for your answer.
I imagine that I have to insert this code
Code: [Select]
echo $manufacturer->images[0]->displayMediaThumb('',false); into template/my-template/html/mod_virtuemart_product/default.php  but I don't understand where I have to insert this code
Code: [Select]
$mf = VmModel::getModel('Manufacturer');
$manufacturer = $mf->getManufacturer($product->virtuemart_manufacturer_id[0]);
$mf->addImages($manufacturer);

Ghost

  • Jr. Member
  • **
  • Posts: 419
Re: Manufacturer Logo in Product Module
« Reply #4 on: February 23, 2016, 22:12:37 pm »
Thank you Ghost for your answer.
I imagine that I have to insert this code
Code: [Select]
echo $manufacturer->images[0]->displayMediaThumb('',false); into template/my-template/html/mod_virtuemart_product/default.php  but I don't understand where I have to insert this code
Code: [Select]
$mf = VmModel::getModel('Manufacturer');
$manufacturer = $mf->getManufacturer($product->virtuemart_manufacturer_id[0]);
$mf->addImages($manufacturer);

First line ($mf = VmModel::getModel('Manufacturer'); ) should be before products loop and the other two inside, before $mf = VmModel::getModel('Manufacturer');.

Geppux

  • Jr. Member
  • **
  • Posts: 173
Re: Manufacturer Logo in Product Module
« Reply #5 on: February 23, 2016, 23:50:59 pm »
Thank you Ghost...but...what is products loop? I'm sorry but my knowledge of php is very low...  :-[
and you are always talking about the file template/my-template/html/mod_virtuemart_product/default.php ? is this the only file to modify?
Thank you, bye.
Giuseppe

Ghost

  • Jr. Member
  • **
  • Posts: 419
Re: Manufacturer Logo in Product Module
« Reply #6 on: February 24, 2016, 07:30:07 am »
Thank you Ghost...but...what is products loop? I'm sorry but my knowledge of php is very low...  :-[
and you are always talking about the file template/my-template/html/mod_virtuemart_product/default.php ? is this the only file to modify?
Thank you, bye.
Giuseppe

Add that first line anywhere before this line:

Code: [Select]
<?php foreach ($products as $product) { ?>
And the other lines after this line.

Geppux

  • Jr. Member
  • **
  • Posts: 173
Re: Manufacturer Logo in Product Module
« Reply #7 on: February 24, 2016, 10:29:22 am »
Thank you Ghost, it works!!!  I was forgetting to insert the code between <?php and ?>  ;D ;D ;D

gpessoa

  • Jr. Member
  • **
  • Posts: 129
Re: Manufacturer Logo in Product Module
« Reply #8 on: March 20, 2019, 15:35:46 pm »
Thank you Ghost for your answer.
I imagine that I have to insert this code
Code: [Select]
echo $manufacturer->images[0]->displayMediaThumb('',false); into template/my-template/html/mod_virtuemart_product/default.php  but I don't understand where I have to insert this code
Code: [Select]
$mf = VmModel::getModel('Manufacturer');
$manufacturer = $mf->getManufacturer($product->virtuemart_manufacturer_id[0]);
$mf->addImages($manufacturer);

First line ($mf = VmModel::getModel('Manufacturer'); ) should be before products loop and the other two inside, before $mf = VmModel::getModel('Manufacturer');.



Is this still doable?
I can’t find any reference to “$mf = VmModel::getModel('Manufacturer');” on product details template!

gpessoa

  • Jr. Member
  • **
  • Posts: 129
Re: [Solved] Manufacturer Logo in Product Module
« Reply #9 on: March 21, 2019, 14:44:32 pm »
I already did this by just changing all the “default_manufacturer” template to the fowling code:

Code: [Select]
<?php
/**
 *
 * Show the product details page
 *
 * @package VirtueMart
 * @author Max Milbers, Valerie Isaksen
 * @link https://virtuemart.net
 * @copyright Copyright (c) 2004 - 2014 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @version $Id: default_manufacturer.php 9821 2018-04-16 18:04:39Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
?>

<div class="manufacturer">
<?php
$i 1;

$mans = array();
// Gebe die Hersteller aus
foreach($this->product->manufacturers as $manufacturers_details) {
//Link to products
$link JRoute::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id=' $manufacturers_details->virtuemart_manufacturer_id'&tmpl=component'FALSE);
$name $manufacturers_details->mf_name;
        
$image $manufacturers_details->images[0];
// Avoid JavaScript on PDF Output
if (!$this->writeJs) {
$mans[] = JHtml::_('link'$link$name);
} else {
$mans[] = '<a class="manuModal" rel="{handler: \'iframe\', size: {x: 700, y: 850}}" href="'.$link .'">'.$image->displayMediaThumb("",false).'</a>';
}
}
echo implode(', ',$mans);
?>

</div>

gpessoa

  • Jr. Member
  • **
  • Posts: 129
Re: [Solved] Manufacturer Logo in Product Module
« Reply #10 on: March 21, 2019, 14:50:50 pm »
From the above code, now I have manufacturer logo on product detail page!

is there same solution to also “echo” manufacturer logo image on category?