Checking on products does not work as an empty query also evaluate to true. So pass nproducts to the template