示例#1
0
 /**
  * Initialize rule model data from array.
  * Set store labels if applicable.
  *
  * @param array $data
  *
  * @return Mage_SalesRule_Model_Rule
  */
 public function loadPost(array $data)
 {
     parent::loadPost($data);
     if (isset($data['store_labels'])) {
         $this->setStoreLabels($data['store_labels']);
     }
     return $this;
 }
 /**
  * Set aggregated conditions SQL and reset sales rule Id if applicable
  *
  * @return Enterprise_Reminder_Model_Rule
  */
 protected function _beforeSave()
 {
     $this->setConditionSql($this->getConditions()->getConditionsSql(null, new Zend_Db_Expr(':website_id')));
     if (!$this->getSalesruleId()) {
         $this->setSalesruleId(null);
     }
     parent::_beforeSave();
     return $this;
 }
示例#3
0
 /**
  * Returns rule as an array for admin interface
  *
  * @deprecated after 1.6.2.0
  *
  * @param array $arrAttributes
  *
  * Output example:
  * array(
  *   'name'=>'Example rule',
  *   'conditions'=>{condition_combine::toArray}
  *   'actions'=>{action_collection::toArray}
  * )
  *
  * @return array
  */
 public function toArray(array $arrAttributes = array())
 {
     return parent::toArray($arrAttributes);
 }
示例#4
0
 /**
  * Set aggregated conditions SQL.
  * Collect and save list of events which are applicable to segment.
  *
  * @return Enterprise_CustomerSegment_Model_Segment
  */
 protected function _beforeSave()
 {
     if (!$this->getData('processing_frequency')) {
         $this->setData('processing_frequency', '1');
     }
     if (!$this->isObjectNew()) {
         // Keep 'apply_to' property without changes for existing customer segments
         $this->setData('apply_to', $this->getOrigData('apply_to'));
     }
     $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();
     return $this;
 }
 /**
  * Callback function which called after transaction commit in resource model
  *
  * @return Enterprise_TargetRule_Model_Rule
  */
 public function _afterDeleteCommit()
 {
     parent::_afterDeleteCommit();
     /** @var \Mage_Index_Model_Indexer $indexer */
     $indexer = Mage::getSingleton('index/indexer');
     $indexer->processEntityAction(new Varien_Object(array('type_id' => $this->getData('apply_to'))), Enterprise_TargetRule_Model_Index::ENTITY_TARGETRULE, Enterprise_TargetRule_Model_Index::EVENT_TYPE_CLEAN_TARGETRULES);
 }
示例#6
0
 protected function _afterLoad()
 {
     parent::_afterLoad();
     if (is_string($this->_getData('payment_methods_ids'))) {
         $this->setPaymentMethodsIds(explode(',', $this->_getData('payment_methods_ids')));
     }
     if (is_string($this->_getData('shipping_methods_ids'))) {
         $this->setShippingMethodsIds(explode(',', $this->_getData('shipping_methods_ids')));
     }
     if (is_string($this->_getData('customer_group_ids'))) {
         $this->setCustomerGroupIds(explode(',', $this->_getData('customer_group_ids')));
     }
     if (is_string($this->_getData('website_ids'))) {
         $this->setWebsiteIds(explode(',', $this->_getData('website_ids')));
     }
 }
示例#7
0
 protected function _afterSave()
 {
     parent::_afterSave();
 }
 /**
  * Validate rule data
  *
  * @param Varien_Object $object
  *
  * @return bool|array - return true if validation passed successfully. Array with errors description otherwise
  */
 public function validateData(Varien_Object $object)
 {
     $result = parent::validateData($object);
     if (!is_array($result)) {
         $result = array();
     }
     $validator = new Zend_Validate_Regex(array('pattern' => '/^[a-z][a-z0-9_\\/]{1,255}$/'));
     $actionArgsList = $object->getData('rule');
     if (is_array($actionArgsList) && isset($actionArgsList['actions'])) {
         foreach ($actionArgsList['actions'] as $actionArgsIndex => $actionArgs) {
             if (1 === $actionArgsIndex) {
                 continue;
             }
             if (!$validator->isValid($actionArgs['type']) || isset($actionArgs['attribute']) && !$validator->isValid($actionArgs['attribute'])) {
                 $result[] = Mage::helper('enterprise_targetrule')->__('Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.');
             }
         }
     }
     return !empty($result) ? $result : true;
 }
 /**
  * Constructor
  */
 protected function _construct()
 {
     parent::_construct();
     $this->_init('easyshippingrules/rule');
     $this->setIdFieldName('easyshippingrules_rule_id');
 }
示例#10
0
 /**
  * Init resource model and id field
  */
 protected function _construct()
 {
     parent::_construct();
     $this->_init('productlist/rule');
 }