Example #1
0
 /**
  * Update quantity of order quote items
  *
  * @param array $items
  * @return $this
  * @throws \Exception|\Magento\Framework\Exception\LocalizedException
  */
 public function updateQuoteItems($items)
 {
     if (!is_array($items)) {
         return $this;
     }
     try {
         foreach ($items as $itemId => $info) {
             if (!empty($info['configured'])) {
                 $item = $this->getQuote()->updateItem($itemId, $this->objectFactory->create($info));
                 $info['qty'] = (double) $item->getQty();
             } else {
                 $item = $this->getQuote()->getItemById($itemId);
                 if (!$item) {
                     continue;
                 }
                 $info['qty'] = (double) $info['qty'];
             }
             $this->quoteItemUpdater->update($item, $info);
             if ($item && !empty($info['action'])) {
                 $this->moveQuoteItem($item, $info['action'], $item->getQty());
             }
         }
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->recollectCart();
         throw $e;
     } catch (\Exception $e) {
         $this->_logger->critical($e);
     }
     $this->recollectCart();
     return $this;
 }