VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: AnthonyWang on July 14, 2016, 09:19:35 AM

Title: How to detect there is no products in category
Post by: AnthonyWang on July 14, 2016, 09:19:35 AM
I have some categroy no has poducts ,
how can i detect if no products in category/default.php ?
i tried some way,but all not work

if (!empty($this->products)) {
$products = array();
$products[0] = $this->products;

if (!empty($products[0])):
     eho 'blablabla....';   // this works
else:
     echo 'no products';  // not work
endif;



Title: Re: How to detect there is no products in category
Post by: Jumbo! on July 14, 2016, 20:51:44 PM
Just use the following codes.

if(empty($this->products))
{
    echo "Sorry, no products found".
}
Title: Re: How to detect there is no products in category
Post by: AnthonyWang on July 15, 2016, 00:13:49 AM
Thanks Jumbo,
I found the issue happen because i write the code in
if (!empty($this->products))
......
anyway thanks!