News:

Support the VirtueMart project and become a member

Main Menu

How to detect there is no products in category

Started by AnthonyWang, July 14, 2016, 09:19:35 AM

Previous topic - Next topic

AnthonyWang

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;



Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

Jumbo!

Just use the following codes.

if(empty($this->products))
{
    echo "Sorry, no products found".
}

AnthonyWang

#2
Thanks Jumbo,
I found the issue happen because i write the code in
if (!empty($this->products))
......
anyway thanks!
Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17