Author Topic: Manufacturer name or image in category page  (Read 1827 times)

godfather21

  • Beginner
  • *
  • Posts: 13
Manufacturer name or image in category page
« 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
Code: [Select]
<!-- 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

godfather21

  • Beginner
  • *
  • Posts: 13
Re: Manufacturer name or image in category page
« Reply #1 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?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26809
  • Always on vacation
    • Jenkin Hill Internet
Re: Manufacturer name or image in category page
« Reply #2 on: December 04, 2015, 12:40:22 pm »
http://forum.virtuemart.net/index.php?topic=104795.0

Quote
i 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
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM3.2.14.9808 on Joomla 3.8.8 PHP 7.0.30

Testing VM3.2.15.9840 on J3.8.8

godfather21

  • Beginner
  • *
  • Posts: 13
Re: Manufacturer name or image in category page
« Reply #3 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.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26809
  • Always on vacation
    • Jenkin Hill Internet
Re: Manufacturer name or image in category page
« Reply #4 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
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM3.2.14.9808 on Joomla 3.8.8 PHP 7.0.30

Testing VM3.2.15.9840 on J3.8.8

godfather21

  • Beginner
  • *
  • Posts: 13
Re: Manufacturer name or image in category page
« Reply #5 on: December 08, 2015, 10:20:26 am »
Thank you very much, i didnt know i can do this

hegbi

  • Beginner
  • *
  • Posts: 21
Re: Manufacturer name or image in category page
« Reply #6 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:
Code: [Select]
<?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

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 640
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always latest
Re: Manufacturer name or image in category page
« Reply #7 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.

Code: [Select]
<?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;
}
?>

hegbi

  • Beginner
  • *
  • Posts: 21
Re: Manufacturer name or image in category page
« Reply #8 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.

Code: [Select]
<?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!!

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 640
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always latest
Re: Manufacturer name or image in category page
« Reply #9 on: June 03, 2016, 16:33:12 pm »
You are welcome. :)

Vincenzo77

  • Beginner
  • *
  • Posts: 4
  • A beginner
  • Skype Name: vincenzo.perna29
  • VirtueMart Version: 3.2.14
Re: Manufacturer name or image in category page
« Reply #10 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

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 2974
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Manufacturer name or image in category page
« Reply #11 on: May 08, 2018, 22:37:15 pm »
You can do same on checking the virtuemart_manufacturer_id in the input
Code: [Select]
$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