Author Topic: How to detect there is no products in category  (Read 463 times)

AnthonyWang

  • Beginner
  • *
  • Posts: 47
  • VirtueMart Version: 3.2.1
How to detect there is no products in category
« 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
Code: [Select]
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!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 679
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always latest
Re: How to detect there is no products in category
« Reply #1 on: July 14, 2016, 20:51:44 pm »
Just use the following codes.

Code: [Select]
if(empty($this->products))
{
    echo "Sorry, no products found".
}

AnthonyWang

  • Beginner
  • *
  • Posts: 47
  • VirtueMart Version: 3.2.1
Re: How to detect there is no products in category
« Reply #2 on: July 15, 2016, 00:13:49 am »
Thanks Jumbo,
I found the issue happen because i write the code in
Code: [Select]
if (!empty($this->products))......
anyway thanks!
Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17