public function getStock()
    {
        if ($this->getStockType() !== ElcodiProductStock::INHERIT_STOCK) {
            return $this->stock;
        }

        $stock = ElcodiProductStock::INFINITE_STOCK;
        foreach ($this->getPurchasables() as $purchasable) {
            $purchasableStock = $purchasable->getStock();
            if (is_int($purchasableStock) && (
                    !is_int($stock) ||
                    $purchasableStock < $stock
                )) {
                $stock = $purchasableStock;
            }
        }

        return $stock;
    }