Ejemplo n.º 1
0
 public function testGetStockQty()
 {
     $productId = 34;
     $result = 3;
     $stockItemModel = $this->getStockItemModel($productId);
     $stockItemModel->expects($this->once())->method('getStockQty')->will($this->returnValue($result));
     $this->assertEquals($result, $this->model->getStockQty($productId));
 }
Ejemplo n.º 2
0
 /**
  * {inheritdoc}
  */
 public function getProductStockStatusBySku($sku)
 {
     $product = $this->productLoader->load($sku);
     $productId = $product->getId();
     if (!$productId) {
         throw new NoSuchEntityException("Product with SKU \"{$sku}\" does not exist");
     }
     $data = $this->stockStatus->getProductStockStatus([$productId], $this->scopeResolver->getScope()->getId());
     $stockStatus = (bool) $data[$productId];
     $result = [Data\StockStatus::STOCK_STATUS => $stockStatus, Data\StockStatus::STOCK_QTY => $this->stockItemService->getStockQty($productId)];
     $this->stockStatusBuilder->populateWithArray($result);
     return $this->stockStatusBuilder->create();
 }
Ejemplo n.º 3
0
 /**
  * Retrieve product stock qty
  *
  * @param Product $product
  * @return float
  */
 public function getProductStockQty($product)
 {
     return $this->stockItemService->getStockQty($product->getId());
 }