/**
  * Returns suggested qty that satisfies qty increments and minQty/maxQty/minSaleQty/maxSaleQty conditions
  * or original qty if such value does not exist
  *
  * @param int $productId
  * @param float $qty
  * @param int $scopeId
  * @return float
  */
 public function suggestQty($productId, $qty, $scopeId = null)
 {
     if ($scopeId === null) {
         $scopeId = $this->stockConfiguration->getDefaultScopeId();
     }
     $stockItem = $this->stockRegistryProvider->getStockItem($productId, $scopeId);
     return $this->stockStateProvider->suggestQty($stockItem, $qty);
 }
示例#2
0
 /**
  * @param StockItemInterface $stockItem
  * @param mixed $expectedResult
  * @dataProvider suggestQtyDataProvider
  */
 public function testSuggestQty(StockItemInterface $stockItem, $expectedResult)
 {
     $this->assertEquals($expectedResult, $this->stockStateProvider->suggestQty($stockItem, $this->qty));
 }