Entity/BaseOrder.php
public function countProducts($type = null)
    {
        $quantity = 0;

        foreach ($this->getOrderElements() as $orderElement) {
            if (!$type || $orderElement->getProduct() instanceof $type) {
                $quantity += $orderElement->getQuantity();
            }
        }

        return $quantity;
    }
public function countProducts($type = null)
    {
        $quantity = 0;

        foreach ($this->getOrderElements() as $orderElement) {
            if (!$type || $orderElement->getProduct() instanceof $type) {
                $quantity += $orderElement->getQuantity();
            }
        }

        return $quantity;
    }
@param null $type

@return int