Author Topic: Manufacturer products count dispplay  (Read 240 times)

julash

  • Beginner
  • *
  • Posts: 20
Manufacturer products count dispplay
« on: September 07, 2017, 09:11:40 am »
Hi,

Website I am upgrading right now sells art. Old site uses category for artist, but there a lot of artist and because of that managing website is a mess right now. So I am using manufacturer as artist of the arts on new website and need to show products count for each manufacturer in manufacturer list page.

I was wondering if it possible to show manufacturer products count. I tried using

<?php echo $manufacturer->number_of_products ?>

and

<?php echo  $this->catmodel->countProducts($manufacturer->virtuemart_manufacturer_id);?>  (from category admin view template)

but no luck. Will appreciate any help.

Thanks
Julash

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10272
  • VirtueMart Version: 3+
Re: Manufacturer products count dispplay
« Reply #1 on: September 08, 2017, 15:14:32 pm »

function to count

function count_man_products($id){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('virtuemart_product_id');
$query->from($db->quoteName('#__virtuemart_product_manufacturers'));
$query->where($db->quoteName('virtuemart_manufacturer_id')." = ".$db->quote($id) );
$db->setQuery($query);
$rows = $db->loadAssocList();
$count=count($rows);
return $count;
}



to use, you just
Inside the
   foreach ( $this->manufacturers as $manufacturer ) {   }


You do
echo count_man_products($manufacturer->virtuemart_manufacturer_id);
I do NOT do development work for hire.

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1302
Re: Manufacturer products count dispplay
« Reply #2 on: September 11, 2017, 14:42:17 pm »
OR

you can try using Custom Filters
https://breakdesigns.net/extensions/custom-filters

julash

  • Beginner
  • *
  • Posts: 20
Re: Manufacturer products count dispplay
« Reply #3 on: September 13, 2017, 08:01:58 am »

function to count

function count_man_products($id){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('virtuemart_product_id');
$query->from($db->quoteName('#__virtuemart_product_manufacturers'));
$query->where($db->quoteName('virtuemart_manufacturer_id')." = ".$db->quote($id) );
$db->setQuery($query);
$rows = $db->loadAssocList();
$count=count($rows);
return $count;
}



to use, you just
Inside the
   foreach ( $this->manufacturers as $manufacturer ) {   }


You do
echo count_man_products($manufacturer->virtuemart_manufacturer_id);

Worked like a charm.  :D :D Thanks for the awesome help.

I think this should be a feature.

Regards
Julash