/**
  * 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);
 }
Example #2
0
 /**
  * @param StockItemInterface $stockItem
  * @param mixed $expectedResult
  * @dataProvider getStockQtyDataProvider
  */
 public function testGetStockQty(StockItemInterface $stockItem, $expectedResult)
 {
     $this->assertEquals($expectedResult, $this->stockStateProvider->getStockQty($stockItem));
 }