News:

Looking for documentation? Take a look on our wiki

Main Menu

Manufacturer name or image in category page

Started by godfather21, December 03, 2015, 13:22:14 PM

Previous topic - Next topic

godfather21

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

godfather21

As i can see no one is replying, do i have to give some more information about this?

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

godfather21

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

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
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

godfather21

Thank you very much, i didnt know i can do this

hegbi

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

Jumbo!

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;
}
?>

hegbi

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!!


Vincenzo77

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

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

kostianev

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;
}
?>