protected function _beforeSave() { if ($this->getCouponCode()) { $this->getResource()->addUniqueField(array('field' => 'coupon_code', 'title' => Mage::helper('salesRule')->__('Coupon with the same code'))); } return parent::_beforeSave(); }
/** * Perform actions before object save. */ protected function _beforeSave() { $this->setConditionSql($this->getConditions()->getConditionsSql(null, new Zend_Db_Expr(':website_id'))); if (!$this->getSalesruleId()) { $this->setSalesruleId(null); } parent::_beforeSave(); }
/** * Reset action cached select if actions conditions has changed * * @return Enterprise_TargetRule_Model_Rule */ protected function _beforeSave() { parent::_beforeSave(); if ($this->dataHasChangedFor('actions_serialized')) { $this->setData('action_select', null); $this->setData('action_select_bind', null); } return $this; }
protected function _beforeSave() { if ($coupon = $this->getCouponCode()) { $this->getResource()->addUniqueField(array('field' => 'coupon_code', 'title' => AO::helper('salesRule')->__('Coupon with the same code'))); AO::app()->cleanCache('salesrule_coupon_' . md5($coupon)); } else { $this->getResource()->resetUniqueField(); } return parent::_beforeSave(); }
protected function _beforeSave() { // Only call the "rule" model parents _beforeSave function if the profile is modified in the backend, as otherwise the "conditions" ("export filters") could be lost if (Mage::app()->getRequest()->getControllerName() == 'orderexport_profile') { parent::_beforeSave(); } else { if (!$this->getId()) { $this->isObjectNew(true); } } }
protected function _beforeSave() { // if (!$this->getId()) // $this->setStatus(Magestore_Customercredit_Model_Status::STATUS_PENDING); if (!$this->getCreditCode()) { $this->setCreditCode('[N.4]-[AN.5]-[A.4]'); } if ($this->_codeIsExpression()) { $this->setCreditCode($this->_getCreditCode()); } return parent::_beforeSave(); }
protected function _beforeSave() { $defaultProgram = Mage::getModel('affiliateplusprogram/program')->load($this->getId()); if ($storeId = $this->getStoreId()) { $storeAttributes = $this->getStoreAttributes(); foreach ($storeAttributes 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)); } if ($defaultProgram->getId()) { $this->setData($attribute, $defaultProgram->getData($attribute)); } } if ($this->getId()) { $totalAttributes = $this->getTotalAttributes(); foreach ($totalAttributes as $attribute) { $attributeValue = Mage::getModel('affiliateplusprogram/value')->loadAttributeValue($this->getId(), $storeId, $attribute); if ($delta = $this->getData($attribute) - $attributeValue->getValue()) { try { $attributeValue->setValue($this->getData($attribute)); $attributeValue->save(); } catch (Exception $e) { } } $this->setData($attribute, $defaultProgram->getData($attribute) + $delta); } } } if (is_array($this->getData('tier_commission'))) { $this->setData('tier_commission', serialize($this->getData('tier_commission'))); } if (is_array($this->getData('tier_commission_value'))) { $this->setData('tier_commission_value', serialize($this->getData('tier_commission_value'))); } if (is_array($this->getData('sec_tier_commission'))) { $this->setData('sec_tier_commission', serialize($this->getData('sec_tier_commission'))); } if (is_array($this->getData('sec_tier_commission_value'))) { $this->setData('sec_tier_commission_value', serialize($this->getData('sec_tier_commission_value'))); } parent::_beforeSave(); if (is_array($this->getCustomerGroupIds())) { $this->setCustomerGroupIds(join(',', $this->getCustomerGroupIds())); } return $this; }
protected function _beforeSave() { $this->_setWebsiteIds(); return parent::_beforeSave(); }
/** * Perform actions before object save. * Collect and save list of events which are applicable to segment. */ protected function _beforeSave() { if (!$this->getData('processing_frequency')) { $this->setData('processing_frequency', '1'); } $events = array(); if ($this->getIsActive()) { $events = $this->collectMatchedEvents(); } $customer = new Zend_Db_Expr(':customer_id'); $website = new Zend_Db_Expr(':website_id'); $this->setConditionSql($this->getConditions()->getConditionsSql($customer, $website)); $this->setMatchedEvents(array_unique($events)); parent::_beforeSave(); }
protected function _beforeSave() { if (isset($_FILES['layout_file']) && $_FILES['layout_file']['name'] != '') { try { $uploader = new Varien_File_Uploader('layout_file'); $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')); $uploader->setAllowRenameFiles(true); $uploader->setFilesDispersion(true); $this->setLayoutFileName($uploader->getCorrectFileName($_FILES['layout_file']['name'])); $ext = pathinfo($_FILES['layout_file']['name'], PATHINFO_EXTENSION); $result = $uploader->save(Mage::getBaseDir('media') . DS . $this->getUploadPath(), uniqid() . "." . $ext); $this->setLayoutFile($this->getUploadPath() . $result['file']); } catch (Exception $e) { Mage::throwException($this->__('Invalid image format')); } } else { $layoutFile = $this->getLayoutFile(); if (isset($layoutFile['delete']) && $layoutFile['delete'] == 1) { $this->setLayoutFile(NULL); } else { $this->setLayoutFile($this->layout_file["value"]); } } return parent::_beforeSave(); }
/** * Prepare data before saving * * @return Mage_Rule_Model_Rule */ protected function _beforeSave() { parent::_beforeSave(); if (is_array($this->getPaymentMethodsIds())) { $this->setPaymentMethodsIds(join(',', $this->getPaymentMethodsIds())); } if (is_array($this->getShippingMethodsIds())) { $this->setShippingMethodsIds(join(',', $this->getShippingMethodsIds())); } if (is_array($this->getCustomerGroupIds())) { $this->setCustomerGroupIds(join(',', $this->getCustomerGroupIds())); } if (is_array($this->getWebsiteIds())) { $this->setWebsiteIds(join(',', $this->getWebsiteIds())); } }
protected function _beforeSave() { parent::_beforeSave(); if ($storeId = $this->getStoreId()) { $defaultLabel = Mage::getModel('rewardpointsreferfriends/rewardpointsspecialrefer')->load($this->getId()); $storeAttributes = $this->getStoreAttributes(); foreach ($storeAttributes 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, $defaultLabel->getData($attribute)); } } if ($this->hasWebsiteIds()) { $websiteIds = $this->getWebsiteIds(); if (is_array($websiteIds) && !empty($websiteIds)) { $this->setWebsiteIds(implode(',', $websiteIds)); } } if ($this->hasCustomerGroupIds()) { $groupIds = $this->getCustomerGroupIds(); if (is_array($groupIds) && !empty($groupIds)) { $this->setCustomerGroupIds(implode(',', $groupIds)); } } return $this; }