You can also write $count += $product->getQuantity();