VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: webmanwebdesign on February 14, 2024, 08:36:56 AM

Title: Show all manufacturers on category view
Post by: webmanwebdesign on February 14, 2024, 08:36:56 AM
Hi there,

is there an option to get all manufacturer names of a product in the category view?
For now I am using $product->mf_name, but this only gives me the first manufacturer selected. The second one is not shown at all.

Kind regards
Tanja
Title: Re: Show all manufacturers on category view
Post by: Jumbo! on February 14, 2024, 12:05:39 PM
You can print all the manufacturer names assigned to a product using the following codes.

<?php

$manufacturerModel 
VmModel::getModel('manufacturer');

if (
is_array($product->virtuemart_manufacturer_id) && count($product->virtuemart_manufacturer_id) > 1) {
  foreach (
$product->virtuemart_manufacturer_id as $manufacturerId) {
    
$manufacturer $manufacturerModel->getManufacturer($manufacturerId);

    echo 
$manufacturer->mf_name;
  }
} elseif (!empty(
$product->mf_name)) {
  echo 
$product->mf_name;
}
Title: Re: Show all manufacturers on category view
Post by: webmanwebdesign on February 15, 2024, 15:17:22 PM
Thank you, Jumbo.

That helped.