Exemplo n.º 1
0
 /**
  * Recalculates order. Starts transactions, deletes current order and order articles from DB,
  * adds current order articles to virtual basket and finaly recalculates order by calling oxorder::finalizeOrder()
  * If no errors, finishing transaction.
  *
  * @param array $aNewArticles article list of new order
  *
  * @return null
  */
 public function recalculateOrder($aNewArticles = array())
 {
     oxDb::startTransaction();
     try {
         $oBasket = $this->_getOrderBasket();
         // add this order articles to virtual basket and recalculates basket
         $this->_addOrderArticlesToBasket($oBasket, $this->getOrderArticles(true));
         // adding new articles to existing order
         $this->_addArticlesToBasket($oBasket, $aNewArticles);
         // recalculating basket
         $oBasket->calculateBasket(true);
         //finalizing order (skipping payment execution, vouchers marking and mail sending)
         $iRet = $this->finalizeOrder($oBasket, $this->getOrderUser(), true);
         //if finalizing order failed, rollback transaction
         if ($iRet !== 1) {
             oxDb::rollbackTransaction();
         } else {
             oxDb::commitTransaction();
         }
     } catch (Exception $oE) {
         // if exception, rollBack everything
         oxDb::rollbackTransaction();
         if (defined('OXID_PHP_UNIT')) {
             throw $oE;
         }
     }
 }
 /**
  * Adding new language to DB - creating new multilangue fields with new
  * language ID (e.g. oxtitle_4)
  *
  * @return null
  */
 protected function _addNewMultilangFieldsToDb()
 {
     //creating new multilanguage fields with new id over whole DB
     oxDb::startTransaction();
     $oDbMeta = oxNew("oxDbMetaDataHandler");
     try {
         $oDbMeta->addNewLangToDb();
     } catch (Exception $oEx) {
         // if exception, rollBack everything
         oxDb::rollbackTransaction();
         //show warning
         echo $oEx->getMessage();
         $oEx = oxNew("oxExceptionToDisplay");
         $oEx->setMessage('LANGUAGE_ERROR_ADDING_MULTILANG_FIELDS');
         oxUtilsView::getInstance()->addErrorToDisplay($oEx);
         return;
     }
     oxDb::commitTransaction();
 }
 /**
  * Resets all multilanguage fields with specific language id
  * to default value in all tables.
  *
  * @param string $iLangId language ID
  *
  * @return null
  */
 protected function _resetMultiLangDbFields($iLangId)
 {
     $iLangId = (int) $iLangId;
     //skipping reseting language with id = 0
     if ($iLangId) {
         oxDb::startTransaction();
         try {
             $oDbMeta = oxNew("oxDbMetaDataHandler");
             $oDbMeta->resetLanguage($iLangId);
             oxDb::commitTransaction();
         } catch (Exception $oEx) {
             // if exception, rollBack everything
             oxDb::rollbackTransaction();
             //show warning
             $oEx = oxNew("oxExceptionToDisplay");
             $oEx->setMessage('LANGUAGE_ERROR_RESETING_MULTILANG_FIELDS');
             oxUtilsView::getInstance()->addErrorToDisplay($oEx);
         }
     }
 }