/** * Retrieve stock qty whether product is composite or no * * @param int $productId * @param int $scopeId * @return float */ public function getStockQty($productId, $scopeId = null) { if ($scopeId === null) { $scopeId = $this->stockConfiguration->getDefaultScopeId(); } $stockItem = $this->stockRegistryProvider->getStockItem($productId, $scopeId); return $this->stockStateProvider->getStockQty($stockItem); }
/** * @param StockItemInterface $stockItem * @param mixed $expectedResult * @dataProvider getStockQtyDataProvider */ public function testGetStockQty(StockItemInterface $stockItem, $expectedResult) { $this->assertEquals($expectedResult, $this->stockStateProvider->getStockQty($stockItem)); }