Exemplo n.º 1
0
 protected function _beforeSave()
 {
     if ($storeId = $this->getStoreId()) {
         $defaultProductFile = Mage::getModel('productfile/productfile')->load($this->getId());
         $productFileAttributes = $this->getProductFlieAttributes();
         foreach ($productFileAttributes as $attribute) {
             if ($this->getData($attribute . '_default')) {
                 $this->setData($attribute . '_in_store', false);
             } else {
                 $this->setData($attribute . '_in_store', true);
                 $this->setData($attribute . '_value', $this->getData($attribute));
             }
             $this->setData($attribute, $defaultProductFile->getData($attribute));
         }
         /*if (($this->getData('filename_in_store')==true) && ($this->getData('filename_value')!= NULL)){
         			try {						
         				$uploader = new Varien_File_Uploader('filename');									
         				$uploader->setAllowRenameFiles(false);					
         				$uploader->setFilesDispersion(true);					
         				$path = Mage::getBaseDir('media') . DS .'productfile' ;
         				$uploader->save($path, $this->getData('filename_value'));											
         			} catch (Exception $e) {		      
         	        }
         		}*/
     }
     return parent::_beforeSave();
 }
Exemplo n.º 2
0
 protected function _beforeSave()
 {
     if ($this->_mediumData) {
         $this->setData('medium_json', $this->_mediumData->toJson());
     }
     parent::_beforeSave();
 }
Exemplo n.º 3
0
 protected function _beforeSave()
 {
     if (!$this->getId()) {
         Mage::register('amorderattach_add_field', true, true);
     }
     return parent::_beforeSave();
 }
Exemplo n.º 4
0
 protected function _beforeSave()
 {
     parent::_beforeSave();
     $this->_updateTimestamps();
     $this->_prepareUrlKey();
     return $this;
 }
Exemplo n.º 5
0
 /**
  * before save anymarket orders
  *
  * @access protected
  * @return DB1_AnyMarket_Model_Anymarketorders
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     $now = Mage::getSingleton('core/date')->gmtDate();
     if ($this->isObjectNew()) {
         $this->setCreatedAt($now);
     }
     $this->setUpdatedAt($now);
     $stores = $this->getStores();
     if ($stores != null) {
         if (is_array($stores)) {
             $storeID = reset($stores);
         }
         if (!is_string($storeID) && !is_integer($storeID)) {
             $this->setStores(array());
         }
     }
     if ($this->getNmoStatusInt() == 'ERROR 02') {
         $anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->load($this->getId());
         if ($this->getNmoIdSeqAnymarket() == "" || $this->getNmoIdSeqAnymarket() == null) {
             $this->setNmoIdSeqAnymarket($anymarketorders->getNmoIdSeqAnymarket());
         }
         if ($this->getNmoIdAnymarket() == "" || $this->getNmoIdAnymarket() == null) {
             $this->setNmoIdAnymarket($anymarketorders->getNmoIdAnymarket());
         }
     }
     return $this;
 }
Exemplo n.º 6
0
 /**
  * Event triggered before save()
  */
 protected function _beforeSave()
 {
     if (!$this->getPageType()) {
         Mage::throwException('Missing Page Type');
     }
     return parent::_beforeSave();
 }
Exemplo n.º 7
0
 /**
  * @return Firegento_FlexCms_Model_Content_Data
  */
 protected function _beforeSave()
 {
     if (is_array($this->getData('content'))) {
         $this->setData('content', Zend_Json::encode($this->getData('content')));
     }
     return parent::_beforeSave();
 }
Exemplo n.º 8
0
 /**
  * Encrypts information before saving to DB
  *
  */
 protected function _beforeSave()
 {
     foreach (array('username', 'password') as $field) {
         $this->setData($field, $this->encrypt($this->getData($field)));
     }
     return parent::_beforeSave();
 }
Exemplo n.º 9
0
 protected function _beforeSave()
 {
     if (Mage::helper('core')->isModuleEnabled('MageB2B_CustomerId') && !$this->getCustomerId()) {
         $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c = Mage::getModel('customer/customer')->load($this->getEntityId());
         if ($_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getCustomerId() && Mage::getStoreConfig('customer_id/customer_id/auto_increment')) {
             $_b80cbfb11fdc80a0dabd8069a0fd063d9d896285 = array();
             $_205d95c001c842f933e3b55fa4e902d5d2fdd0af = Mage::getModel('sublogin/sublogin')->getCollection()->addFieldToFilter('entity_id', $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getId());
             foreach ($_205d95c001c842f933e3b55fa4e902d5d2fdd0af as $_4e45fa4f3249d9c3cc1314ed89922593008cf117) {
                 $_b80cbfb11fdc80a0dabd8069a0fd063d9d896285[] = $_4e45fa4f3249d9c3cc1314ed89922593008cf117->getCustomerId();
             }
             $_205d95c001c842f933e3b55fa4e902d5d2fdd0af = Mage::getModel('sublogin/sublogin')->getCollection()->addFieldToFilter('entity_id', $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getId())->addOrder('id', 'asc');
             $_e5063eb1568e4b8089f8c18b623e0363b782b74c = 1;
             while (in_array($_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getCustomerId() . '-' . $_e5063eb1568e4b8089f8c18b623e0363b782b74c, $_b80cbfb11fdc80a0dabd8069a0fd063d9d896285)) {
                 $_e5063eb1568e4b8089f8c18b623e0363b782b74c++;
             }
             $this->setCustomerId($_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getCustomerId() . '-' . $_e5063eb1568e4b8089f8c18b623e0363b782b74c);
         }
     }
     $_36276558859e15204f0e389493057edad0cad1cf = Mage::getModel('newsletter/subscriber')->loadByEmail($this->getEmail());
     if ((int) $this->getData('is_subscribed')) {
         if (!$_36276558859e15204f0e389493057edad0cad1cf->getId()) {
             Mage::getModel('newsletter/subscriber')->subscribe($this->getEmail());
         }
     } else {
         $_36276558859e15204f0e389493057edad0cad1cf->unsubscribe();
     }
     if (!$this->getData('expire_date') || $this->getData('expire_date') === null || $this->getData('expire_date') == '0000-00-00') {
         $this->setExpireDate(new Zend_Db_Expr('0000-00-00'));
     }
     parent::_beforeSave();
 }
Exemplo n.º 10
0
 protected function _beforeSave()
 {
     if (is_array($this->getCategoryIds())) {
         $this->setCategoryIds(implode(',', $this->getCategoryIds()));
     }
     return parent::_beforeSave();
 }
Exemplo n.º 11
0
 protected function _beforeSave()
 {
     parent::_beforeSave();
     $actionsXML = $this->getData('actions_xml');
     if (strlen($actionsXML) < 0 && @simplexml_load_string('<data>' . $actionsXML . '</data>', null, LIBXML_NOERROR) === false) {
         Mage::throwException(Mage::helper("dataflow")->__("Actions XML is not valid."));
     }
     if (is_array($this->getGuiData())) {
         $data = $this->getData();
         $guiData = $this->getGuiData();
         if (isset($guiData['file']['type']) && $guiData['file']['type'] == 'file') {
             if (strlen($guiData['file']['path']) == 0 || strlen($guiData['file']['path']) == 1 && in_array($guiData['file']['path'], array('\\', '/', '.', '!', '@', '#', '$', '%', '&', '*', '~', '^'))) {
                 $guiData['file']['path'] = self::DEFAULT_EXPORT_PATH;
             }
             if (strlen($guiData['file']['filename']) == 0) {
                 $guiData['file']['filename'] = self::DEFAULT_EXPORT_FILENAME . $data['entity_type'] . '.' . ($guiData['parse']['type'] == 'csv' ? $guiData['parse']['type'] : 'xml');
             }
             $this->setGuiData($guiData);
         }
         //        	echo '<pre>';
         //        	print_r($this->getGuiData());
         $this->_parseGuiData();
         $this->setGuiData(serialize($this->getGuiData()));
     }
     if ($this->_getResource()->isProfileExists($this->getName(), $this->getId())) {
         Mage::throwException(Mage::helper("dataflow")->__("Profile with the same name already exists."));
     }
 }
Exemplo n.º 12
0
 /**
  * Set some data automatically before saving model
  *
  * @return Enterprise_Logging_Model_Event
  */
 protected function _beforeSave()
 {
     $this->_calculateDifference();
     $this->setOriginalData(serialize($this->getOriginalData()));
     $this->setResultData(serialize($this->getResultData()));
     return parent::_beforeSave();
 }
Exemplo n.º 13
0
 /**
  * Processing object before save data
  *
  * @return Mage_Core_Model_Abstract
  */
 protected function _beforeSave()
 {
     if (!$this->getRuleId() && $this->_rule instanceof Mage_SalesRule_Model_Rule) {
         $this->setRuleId($this->_rule->getId());
     }
     return parent::_beforeSave();
 }
Exemplo n.º 14
0
 protected function _beforeSave()
 {
     $io = new Varien_Io_File();
     $realPath = $io->getCleanPath(Mage::getBaseDir() . '/' . $this->getSitemapPath());
     /**
      * Check path is allow
      */
     if (!$io->allowedPath($realPath, Mage::getBaseDir())) {
         Mage::throwException(Mage::helper('sitemap')->__('Please define correct path'));
     }
     /**
      * Check exists and writeable path
      */
     if (!$io->fileExists($realPath, false)) {
         Mage::throwException(Mage::helper('sitemap')->__('Please create the specified folder "%s" before saving the sitemap.', Mage::helper('core')->htmlEscape($this->getSitemapPath())));
     }
     if (!$io->isWriteable($realPath)) {
         Mage::throwException(Mage::helper('sitemap')->__('Please make sure that "%s" is writable by web-server.', $this->getSitemapPath()));
     }
     /**
      * Check allow filename
      */
     if (!preg_match('#^[a-zA-Z0-9_\\.]+$#', $this->getSitemapFilename())) {
         Mage::throwException(Mage::helper('sitemap')->__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'));
     }
     if (!preg_match('#\\.xml$#', $this->getSitemapFilename())) {
         $this->setSitemapFilename($this->getSitemapFilename() . '.xml');
     }
     $this->setSitemapPath(rtrim(str_replace(str_replace('\\', '/', Mage::getBaseDir()), '', $realPath), '/') . '/');
     return parent::_beforeSave();
 }
 /**
  * Processing object before save data
  *
  * @return Maverick_Crawler_Model_Crawler
  */
 protected function _beforeSave()
 {
     if ($type = $this->getType()) {
         Mage::dispatchEvent($type . '_save_before', $this->_getEventData());
     }
     return parent::_beforeSave();
 }
Exemplo n.º 16
0
 public function _beforeSave()
 {
     if (is_array($this->getData('tags'))) {
         $this->setData('tags', implode(",", $this->getData('tags')));
     }
     return parent::_beforeSave();
 }
Exemplo n.º 17
0
 /**
  * Check order id
  *
  * @return Mage_Core_Model_Abstract
  */
 public function _beforeSave()
 {
     if (null == $this->getOrderId()) {
         throw new Exception(Mage::helper('downloadable')->__('Order id cannot be null'));
     }
     return parent::_beforeSave();
 }
Exemplo n.º 18
0
 public function _beforeSave()
 {
     if ($this->exists() && !$this->getId()) {
         $this->_dataSaveAllowed = false;
     }
     return parent::_beforeSave();
 }
 /**
  * Processing object before save data
  *
  * @return FireGento_AdminMonitoring_Model_History
  */
 protected function _beforeSave()
 {
     if (Mage::helper('firegento_adminmonitoring')->isAdminUserIdExcluded($this->getData('user_id')) && !$this->_forcedLogging) {
         $this->_dataSaveAllowed = false;
     }
     return parent::_beforeSave();
 }
 /**
  * {@inheritdoc}
  */
 public function _beforeSave()
 {
     if ($this->getParentRequest()) {
         $this->setRequestId($this->getParentRequest()->getId());
     }
     parent::_beforeSave();
 }
Exemplo n.º 21
0
 /**
  * @return $this
  */
 protected function _beforeSave()
 {
     if (!$this->getName()) {
         throw new DomainException("Vehicle must have a name");
     }
     return parent::_beforeSave();
 }
Exemplo n.º 22
0
 /**
  * Processing object before save data
  *
  * @return Mage_Core_Model_Abstract
  */
 protected function _beforeSave()
 {
     if (!$this->getVoteTime()) {
         $this->setVoteTime(Mage::getSingleton('core/date')->gmtDate());
     }
     return parent::_beforeSave();
 }
Exemplo n.º 23
0
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if ($this->getParentItem()) {
         $this->setParentItemId($this->getParentItem()->getId());
     }
     return $this;
 }
Exemplo n.º 24
0
 public function _beforeSave()
 {
     parent::_beforeSave();
     if (!$this->getUid()) {
         $uid = md5(Mage::getSingleton('core/date')->gmtDate() . Mage::helper('mstcore/string')->generateRandHeavy(100));
         $this->setUid($uid);
     }
 }
Exemplo n.º 25
0
 /**
  * Prevent blocks recursion
  *
  * @throws Mage_Core_Exception
  * @return Mage_Core_Model_Abstract
  */
 protected function _beforeSave()
 {
     $needle = 'block_id="' . $this->getBlockId() . '"';
     if (false == strstr($this->getContent(), $needle)) {
         return parent::_beforeSave();
     }
     Mage::throwException(Mage::helper('Mage_Cms_Helper_Data')->__('The static block content cannot contain  directive with its self.'));
 }
 /**
  * Set current store before save
  *
  * @return Mage_Catalog_Model_Product_Compare_Item
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (!$this->hasStoreId()) {
         $this->setStoreId(Mage::app()->getStore()->getId());
     }
     return $this;
 }
 /**
  * 
  */
 protected function _beforeSave()
 {
     if (!$this->getData('store_id')) {
         $this->setStoreId(Mage::app()->getStore()->getStoreId());
     }
     $this->setCreationTime($this->__getCurrentGMT());
     return parent::_beforeSave();
 }
Exemplo n.º 28
0
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (is_array($this->getGuiData())) {
         $this->_parseGuiData();
         $this->setGuiData(serialize($this->getGuiData()));
     }
 }
Exemplo n.º 29
0
 protected function _beforeSave()
 {
     $this->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate());
     if ($this->isObjectNew() && null === $this->getCreatedAt()) {
         $this->setCreatedAt(Mage::getSingleton('core/date')->gmtDate());
     }
     return parent::_beforeSave();
 }
Exemplo n.º 30
0
 /**
  * If object is new adds creation date
  *
  * @return NoPro_Bluemoon_Model_Bluemoon
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if ($this->isObjectNew()) {
         $this->setData('created_at', Varien_Date::now());
     }
     return $this;
 }