Exemplo n.º 1
0
 private function changeProductQty(\Ess\M2ePro\Model\Magento\Product $magentoProduct, \Ess\M2ePro\Model\Magento\Product\StockItem $magentoStockItem, $action, $qty)
 {
     $result = true;
     switch ($action) {
         case self::ACTION_ADD:
             $magentoStockItem->addQty($qty, false);
             break;
         case self::ACTION_SUB:
             try {
                 $magentoStockItem->subtractQty($qty, false);
             } catch (\Exception $e) {
                 $result = false;
                 $this->order->addErrorLog('QTY for Product "%name%" cannot be reserved. Reason: %msg%', array('!name' => $magentoProduct->getName(), 'msg' => $e->getMessage()));
             }
             break;
     }
     return $result;
 }