VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: konstantin-shkodskih on January 29, 2013, 06:43:46 AM

Title: Perhaps unnecessary loop foreach () to count the number of products
Post by: konstantin-shkodskih on January 29, 2013, 06:43:46 AM
I noticed in your category template file \components\com_virtuemart\views\category\tmpl\default.php following:
$BrowseTotalProducts = 0;
foreach ($this->products as $product) {
$BrowseTotalProducts++;
}


Can I use: $ this-> category-> productcount,
then there is a need for this code? (ibid. appropriate comment from Max Milbers)
(VirtueMart v.2.0.18a)
Title: Re: Perhaps unnecessary loop foreach () to count the number of products
Post by: PRO on January 29, 2013, 13:23:32 PM
does that code work???


Title: Re: Perhaps unnecessary loop foreach () to count the number of products
Post by: Milbo on January 29, 2013, 14:46:22 PM
$BrowseTotalProducts = count($this->products);

should work, but not productcount,imho. totalproducts is the amount of products which you see, productcount is the value of all products in the category.