VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: godfather21 on December 03, 2015, 13:22:14 PM

Title: Manufacturer name or image in category page
Post by: godfather21 on December 03, 2015, 13:22:14 PM
Hello,

i would like to ask you how can i show the manufacturer name and/ or image in the category page view, my template override has the following
<!-- Show Products -->
<?php
if (!empty(
$this->products)) {
$products = array();
$products[0] = $this->products;
echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));

?>

and i cannot make any modification, can you please help me?

Joomla 3.4.5
Virtuemart 3.0.9
Title: Re: Manufacturer name or image in category page
Post by: godfather21 on December 04, 2015, 11:49:10 AM
As i can see no one is replying, do i have to give some more information about this?
Title: Re: Manufacturer name or image in category page
Post by: jenkinhill on December 04, 2015, 12:40:22 PM
http://forum.virtuemart.net/index.php?topic=104795.0

Quotei cannot make any modification
Please explain this.

You should be using VM3.0.12 now. http://virtuemart.net/news/latest-news/473-security-release-virtuemart-3-0-12
Title: Re: Manufacturer name or image in category page
Post by: godfather21 on December 04, 2015, 13:12:51 PM
I cannot make any modification because it is not like the old virtuemart 2 there where everything was clear and with echo, now it takes everything with a single command as an array.
Title: Re: Manufacturer name or image in category page
Post by: jenkinhill on December 04, 2015, 15:30:52 PM
No. Templating is much more flexible now.  That code line calls a sublayout file to display the product. That file is 'products' - so you need to edit & override components/com_virtuemart/sublayouts/products.php

Add the code <?php echo $product->mf_name ?> wherever is suitable for your layout.

http://docs.virtuemart.net/tutorials/templating-layouts/199-sublayouts.html
Title: Re: Manufacturer name or image in category page
Post by: godfather21 on December 08, 2015, 10:20:26 AM
Thank you very much, i didnt know i can do this
Title: Re: Manufacturer name or image in category page
Post by: hegbi on June 01, 2016, 15:19:50 PM
Hello,
<?php echo $product->mf_name ?> is great if you have only one manufacturer per product.

Is there a way to show all manufacturers on category page, if you have more than one manufacturer per product?

For product details this works:
<?php
// Manufacturer of the Product
if (VmConfig::get('show_manufacturers'1) && !empty($this->product->virtuemart_manufacturer_id)) {
    echo $this->loadTemplate('manufacturer');
?>

but how to do the same for a category page?

VM3.0.16 on Joomla 3.5.1
Title: Re: Manufacturer name or image in category page
Post by: Jumbo! on June 01, 2016, 17:02:36 PM
Override layout file - components/com_virtuemart/sublayouts/products.php in your template.

You can use the following codes to retrieve manufacturer thumbnail image within foreach ($products as $product) loop.


<?php if(!empty($product->virtuemart_manufacturer_id))
{
$model VmModel::getModel('manufacturer');

foreach($product->virtuemart_manufacturer_id as $manufacturer_id)
{
$model->setId($manufacturer_id);
$manufacturer $model->getManufacturer();
$model->addImages($manufacturer);

$thumbnail_image $manufacturer->images[0]->displayMediaThumb('class="mfg-thumbnail-image"'false);

echo $thumbnail_image;
}
?>
Title: Re: Manufacturer name or image in category page
Post by: hegbi on June 01, 2016, 17:30:49 PM
Thank you Jumbo!!!

your code works for images as is, but I wanted to show only name of manufacturers (mf_name) so I made a few changes to your code and it works great.

<?php 
if(!empty($product->virtuemart_manufacturer_id))
{
$model VmModel::getModel('manufacturer');
$mans = array();
foreach($product->virtuemart_manufacturer_id as $manufacturer_id)
{
$model->setId($manufacturer_id);
$manufacturer $model->getManufacturer();
$link JRoute::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id=' $manufacturer_id);
$name $manufacturer->mf_name;
$mans[] = JHtml::_('link'$link$name);
}

} echo 
implode(', ',$mans);?>


thank you so much for your help and prompt reply!!
Title: Re: Manufacturer name or image in category page
Post by: Jumbo! on June 03, 2016, 16:33:12 PM
You are welcome. :)
Title: Re: Manufacturer name or image in category page
Post by: Vincenzo77 on May 08, 2018, 18:54:28 PM
Good afternoon,

I used the following code inside the sublayouts \ products.php file:
-------------------------------------------------------------------------------------------------------------------------
<?php
               if(!empty($product->virtuemart_manufacturer_id))
{
   $model = VmModel::getModel('manufacturer');
   $mans = array();
   foreach($product->virtuemart_manufacturer_id as $manufacturer_id)
   {
      $model->setId($manufacturer_id);
      $manufacturer = $model->getManufacturer();
      $link = JRoute::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id=' . $manufacturer_id);
      $name = $manufacturer->mf_name;
      $mans[] = JHtml::_('link', $link, $name);
   }
   
} echo implode(', ',$mans);?>
-------------------------------------------------------------------------------------------------------------------------

it works fine, but I can not show mf_name in the category \ default.php
Is it possible to insert it?

Joomla 3.8.7
Virtuemart 3.2.14
Title: Re: Manufacturer name or image in category page
Post by: Studio 42 on May 08, 2018, 22:37:15 PM
You can do same on checking the virtuemart_manufacturer_id in the input
$virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id' ,0);
if($virtuemart_manufacturer_id)   {
$model = VmModel::getModel('manufacturer');
      $model->setId($manufacturer_id);
      $manufacturer = $model->getManufacturer();
      $link = JRoute::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id=' . $manufacturer_id);
      $name = $manufacturer->mf_name;
      echo JHtml::_('link', $link, $name);
}

Of course, the manufacturer have to be filtered
Title: Re: Manufacturer name or image in category page
Post by: kostianev on July 15, 2018, 13:13:02 PM
Hi, this code works perfect for me, but is it possible to add and link for the manufacturer page with products when click over the logo image of the manufacturer?

Quote from: Jumbo! on June 01, 2016, 17:02:36 PM
Override layout file - components/com_virtuemart/sublayouts/products.php in your template.

You can use the following codes to retrieve manufacturer thumbnail image within foreach ($products as $product) loop.


<?php if(!empty($product->virtuemart_manufacturer_id))
{
$model VmModel::getModel('manufacturer');

foreach($product->virtuemart_manufacturer_id as $manufacturer_id)
{
$model->setId($manufacturer_id);
$manufacturer $model->getManufacturer();
$model->addImages($manufacturer);

$thumbnail_image $manufacturer->images[0]->displayMediaThumb('class="mfg-thumbnail-image"'false);

echo $thumbnail_image;
}
?>