News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

[Solved] Manufacturer Logo in Product Module

Started by Geppux, February 22, 2016, 18:12:33 PM

Previous topic - Next topic

Geppux

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:
<?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:
<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

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: <img src="images/<?php echo $product->mf_name ?>.png">
But no success... any Idea???
Giuseppe

Ghost

#2
Add images:
$mf = VmModel::getModel('Manufacturer');
$manufacturer = $mf->getManufacturer($product->virtuemart_manufacturer_id[0]);
$mf->addImages($manufacturer);
Call them like this: echo $manufacturer->images[0]->displayMediaThumb('',false);

Or if you just need image URL:

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

Geppux

Thank you Ghost for your answer.
I imagine that I have to insert this code 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 $mf = VmModel::getModel('Manufacturer');
$manufacturer = $mf->getManufacturer($product->virtuemart_manufacturer_id[0]);
$mf->addImages($manufacturer);


Ghost

Quote from: Geppux on February 23, 2016, 12:33:01 PM
Thank you Ghost for your answer.
I imagine that I have to insert this code 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 $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

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

Quote from: Geppux 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

Add that first line anywhere before this line:

<?php foreach ($products as $product) { ?>

And the other lines after this line.

Geppux

Thank you Ghost, it works!!!  I was forgetting to insert the code between <?php and ?>  ;D ;D ;D

gpessoa

Quote from: Ghost on February 23, 2016, 22:12:37 PM
Quote from: Geppux on February 23, 2016, 12:33:01 PM
Thank you Ghost for your answer.
I imagine that I have to insert this code 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 $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!
J 3.10.5; VM 3.4.2; PHP 7.2.34

gpessoa

I already did this by just changing all the "default_manufacturer" template to the fowling code:

<?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>
J 3.10.5; VM 3.4.2; PHP 7.2.34

gpessoa

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?
J 3.10.5; VM 3.4.2; PHP 7.2.34