Пример #1
0
 /**
  * Add one item to basket. Handle eventual errors.
  *
  * @param oxBasket $basket
  * @param array    $itemData
  * @param string   $errorDestination
  *
  * @return null|oxBasketItem
  */
 protected function addItemToBasket($basket, $itemData, $errorDestination)
 {
     $basketItem = null;
     try {
         $basketItem = $basket->addToBasket($itemData['id'], $itemData['amount'], $itemData['selectList'], $itemData['persistentParameters'], $itemData['override'], $itemData['bundle'], $itemData['oldBasketItemId']);
     } catch (\OxidEsales\EshopCommunity\Core\Exception\OutOfStockException $exception) {
         $exception->setDestination($errorDestination);
         // #950 Change error destination to basket popup
         if (!$errorDestination && $this->getConfig()->getConfigParam('iNewBasketItemMessage') == 2) {
             $errorDestination = 'popup';
         }
         oxRegistry::get("oxUtilsView")->addErrorToDisplay($exception, false, (bool) $errorDestination, $errorDestination);
     } catch (\OxidEsales\EshopCommunity\Core\Exception\ArticleInputException $exception) {
         //add to display at specific position
         $exception->setDestination($errorDestination);
         oxRegistry::get("oxUtilsView")->addErrorToDisplay($exception, false, (bool) $errorDestination, $errorDestination);
     } catch (\OxidEsales\EshopCommunity\Core\Exception\NoArticleException $exception) {
         //ignored, best solution F ?
     }
     return $basketItem;
 }