예제 #1
0
 /**
  * Save the discount.
  * Assigns a value to oxsort, if it was null
  * Does input validation before saving the discount.
  *
  * Returns saving status
  *
  * @throws \oxInputException
  * @throws StandardException
  *
  * @return bool
  */
 public function save()
 {
     // Auto assign oxsort, if it is null
     $oxsort = $this->oxdiscount__oxsort->value;
     if (is_null($oxsort)) {
         $shopId = $this->oxdiscount__oxshopid->value;
         $newSort = $this->getNextOxsort($shopId);
         $this->oxdiscount__oxsort = new \oxField($newSort, \oxField::T_RAW);
     }
     // Validate oxsort before saving
     if (!is_numeric($this->oxdiscount__oxsort->value)) {
         $exception = oxNew('oxInputException');
         $exception->setMessage('DISCOUNT_ERROR_OXSORT_NOT_A_NUMBER');
         throw $exception;
     }
     try {
         $saveStatus = parent::save();
     } catch (\OxidEsales\EshopCommunity\Core\Exception\StandardException $exception) {
         if ($exception->getCode() == 1062 && false !== strpos($exception->getMessage(), 'UNIQ_OXSORT')) {
             $exception = oxNew('oxInputException');
             $exception->setMessage('DISCOUNT_ERROR_OXSORT_NOT_UNIQUE');
         }
         throw $exception;
     }
     return $saveStatus;
 }
예제 #2
0
 /**
  * Save this Object to database, insert or update as needed.
  *
  * @return mixed
  */
 public function save()
 {
     $blSaved = parent::save();
     if ($blSaved && $this->oxcontents__oxloadid->value === 'oxagb') {
         $sShopId = $this->getConfig()->getShopId();
         $sVersion = $this->oxcontents__oxtermversion->value;
         $oDb = oxDb::getDb();
         // dropping expired..
         $oDb->execute("delete from oxacceptedterms where oxshopid='{$sShopId}' and oxtermversion != " . $oDb->quote($sVersion));
     }
     return $blSaved;
 }
예제 #3
0
 /**
  * (oxArticle::_saveArtLongDesc()) save the object using parent::save() method.
  *
  * @return bool
  */
 public function save()
 {
     $this->_assignParentDependFields();
     if ($blRet = parent::save()) {
         // saving long description
         $this->_saveArtLongDesc();
     }
     return $blRet;
 }
예제 #4
0
 /**
  * Makes sure that image values (oxpic1 - oxpic12, oxthumb, oxicon) are only base name by striping
  * any dir information and leave only original file name and, saves long description
  * (oxArticle::_saveArtLongDesc()) finally save the object using parent::save() method.
  *
  * @return bool
  */
 public function save()
 {
     // @deprecated since 20110821. folders are no more written, getters must be user for urls
     $this->oxarticles__oxthumb = new oxField(basename($this->oxarticles__oxthumb->value), oxField::T_RAW);
     $this->oxarticles__oxicon = new oxField(basename($this->oxarticles__oxicon->value), oxField::T_RAW);
     $iPicCount = $this->getConfig()->getConfigParam('iPicCount');
     for ($i = 1; $i <= $iPicCount; $i++) {
         $sFieldName = 'oxarticles__oxpic' . $i;
         if (isset($this->{$sFieldName})) {
             $this->_setFieldData($sFieldName, basename($this->{$sFieldName}->value), oxField::T_RAW);
         }
     }
     // @end deprecated
     if ($blRet = parent::save()) {
         // saving long descrition
         $this->_saveArtLongDesc();
     }
     return $blRet;
 }