Exemplo n.º 1
0
 /**
  * @param int $idStockType
  * @param int $idProduct
  *
  * @throws \Spryker\Zed\Stock\Business\Exception\StockProductAlreadyExistsException
  *
  * @return void
  */
 public function checkStockDoesNotExist($idStockType, $idProduct)
 {
     $stockProductQuery = $this->queryContainer->queryStockProductByStockAndProduct($idStockType, $idProduct);
     if ($stockProductQuery->count() > 0) {
         throw new StockProductAlreadyExistsException('Cannot duplicate entry: this stock type is already set for this product');
     }
 }
Exemplo n.º 2
0
 /**
  * @param string $sku
  * @param string $stockType
  * @param int $incrementBy
  *
  * @return void
  */
 public function incrementStock($sku, $stockType, $incrementBy = 1)
 {
     Propel::getConnection()->beginTransaction();
     $idProduct = $this->reader->getProductConcreteIdBySku($sku);
     $idStock = $this->reader->getStockTypeIdByName($stockType);
     $stockProductEntity = $this->queryContainer->queryStockProductByStockAndProduct($idStock, $idProduct)->findOneOrCreate();
     $stockProductEntity->increment($incrementBy);
     $this->insertActiveTouchRecordStockProduct($stockProductEntity);
     Propel::getConnection()->commit();
 }