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
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);
OR
you can try using Custom Filters
https://breakdesigns.net/extensions/custom-filters
Quote from: PRO 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);
Worked like a charm. :D :D Thanks for the awesome help.
I think this should be a feature.
Regards
Julash