Prefer use !empty if getProductsForGroups can return null. I let you take a look