示例#1
0
 public function testGetValueElement()
 {
     /** @var Mage_Rule_Model_Condition_Abstract $model */
     $model = $this->getMockForAbstractClass('Mage_Rule_Model_Condition_Abstract', array(), '', true, true, true, array('getValueElementRenderer'));
     $model->expects($this->any())->method('getValueElementRenderer')->will($this->returnValue(new Mage_Rule_Block_Editable()));
     $rule = new Mage_Rule_Model_Rule();
     $model->setRule($rule->setForm(new Varien_Data_Form()));
     $property = new ReflectionProperty('Mage_Rule_Model_Condition_Abstract', '_inputType');
     $property->setAccessible(true);
     $property->setValue($model, 'date');
     $element = $model->getValueElement();
     $this->assertNotNull($element);
     $this->assertNotEmpty($element->getDateFormat());
 }
示例#2
0
 /**
  * Returns rule as an array for admin interface
  *
  * Output example:
  * array(
  *   'name'=>'Example rule',
  *   'conditions'=>{condition_combine::toArray}
  *   'actions'=>{action_collection::toArray}
  * )
  *
  * @return array
  */
 public function toArray(array $arrAttributes = array())
 {
     $out = parent::toArray($arrAttributes);
     $out['customer_registered'] = $this->getCustomerRegistered();
     $out['customer_new_buyer'] = $this->getCustomerNewBuyer();
     return $out;
 }
示例#3
0
 /**
  * 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();
 }
示例#4
0
 public function _construct()
 {
     parent::_construct();
     $this->_init('rewardpoints/pointrules');
     //('rewardpoints/pointrules')->checkRule($to_validate);
     $this->_types = array(self::RULE_TYPE_CART => Mage::helper('rewardpoints')->__('Cart rule'), self::RULE_TYPE_DATAFLOW => Mage::helper('rewardpoints')->__('Import rule'));
     $this->_action_types = array(self::RULE_ACTION_TYPE_ADD => Mage::helper('rewardpoints')->__('Add / remove points'), self::RULE_ACTION_TYPE_DONTPROCESS => Mage::helper('rewardpoints')->__("Don't process points"));
 }
示例#5
0
 protected function _afterSave()
 {
     //Saving attributes used in rule
     $ruleProductAttributes = array_merge($this->_getUsedAttributes($this->getConditionsSerialized()), $this->_getUsedAttributes($this->getActionsSerialized()));
     if (count($ruleProductAttributes)) {
         $this->getResource()->saveAttributes($this->getId(), $ruleProductAttributes);
     }
     return parent::_afterSave();
 }
示例#6
0
 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);
         }
     }
 }
示例#7
0
 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();
 }
 public function validate(Varien_Object $object)
 {
     // if ($object->hasData('customer')) {
     //     $customer = $object->getData('customer');
     //     $object->setData('customer_group_id', $customer->getGroupId());
     //     $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
     //     $object->setData('is_subscriber', $subscriber->getId() ? 1 : 0);
     //     $reviews = Mage::getModel('review/review')->getCollection()
     //         ->addFieldToFilter('customer_id', $customer->getId());
     //     $object->setData('reviews_count', $reviews->count());
     //     $customerTotals = Mage::getResourceModel('sales/sale_collection')
     //         ->setCustomerFilter($customer)
     //         ->setOrderStateFilter(Mage_Sales_Model_Order::STATE_CANCELED, true)
     //         ->load()
     //         ->getTotals();
     //     $object->setData('sales_amount', $customerTotals['lifetime']);
     // } else {
     //     $object->setData('customer_group_id', 0);
     // }
     // if ($object->hasData('quote')) {
     //     $quote = $object->getData('quote');
     //     $totals = $quote->getTotals();
     //     $object->setData('quote_grand_total', $totals['grand_total']->getValue());
     //     $object->setData('quote_items_summary_qty', $quote->getItemsSummaryQty());
     //     $skus = array();
     //     foreach ($quote->getItemsCollection() as $item) {
     //         $skus[] = $item->getProduct()->getSku();
     //     }
     //     $object->setData('sku', $skus);
     // }
     // if ($object->hasData('order')) {
     //     $order = $object->getData('order');
     //     $qty   = 0;
     //     $skus  = array();
     //     foreach ($order->getAllItems() as $item) {
     //         $skus[] = $item->getProduct()->getSku();
     //         $qty += $item->getQtyOrdered();
     //     }
     //     $object->setData('sku', $skus);
     //     $object->setData('order_grand_total', $order->getGrandTotal());
     //     $object->setData('order_items_summary_qty', $qty);
     // }
     return parent::validate($object);
 }
示例#9
0
 /**
  * Save rule labels after rule save and process product attributes used in actions and conditions
  *
  * @return Mage_SalesRule_Model_Rule
  */
 protected function _afterSave()
 {
     if ($this->hasStoreLabels()) {
         $this->_getResource()->saveStoreLabels($this->getId(), $this->getStoreLabels());
     }
     $couponCode = trim($this->getCouponCode());
     if ($couponCode && $this->getCouponType() == self::COUPON_TYPE_SPECIFIC) {
         $this->getPrimaryCoupon()->setCode($couponCode)->setUsageLimit($this->getUsesPerCoupon() ? $this->getUsesPerCoupon() : null)->setUsagePerCustomer($this->getUsesPerCustomer() ? $this->getUsesPerCustomer() : null)->setExpirationDate($this->getToDate())->save();
     } else {
         $this->getPrimaryCoupon()->delete();
     }
     //Saving attributes used in rule
     $ruleProductAttributes = array_merge($this->_getUsedAttributes($this->getConditionsSerialized()), $this->_getUsedAttributes($this->getActionsSerialized()));
     if (count($ruleProductAttributes)) {
         $this->getResource()->setActualProductAttributes($this, $ruleProductAttributes);
     }
     return parent::_afterSave();
 }
示例#10
0
 /**
  * Limit rule entity model on after load
  *
  * @param Mage_Rule_Model_Rule $model
  *
  * @return void
  */
 public function ruleLoadAfter($model)
 {
     $websiteIds = (array) $model->getData('website_ids');
     // Set rule entity model as non-deletable if role has no exclusive access to assigned to rule entity websites
     if (!$this->_role->hasExclusiveAccess($websiteIds)) {
         $model->setIsDeleteable(false);
     }
     // Set rule entity model as readonly if role has no allowed website ids
     if (!$this->_role->getIsWebsiteLevel()) {
         $model->setIsReadonly(true);
     }
 }
 public function getConditions()
 {
     parent::getConditions();
     $this->_conditions->setPaymentMethodCode($this->_getPaymentMethodCode());
     return $this->_conditions;
 }
示例#12
0
 /**
  * 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();
 }
示例#13
0
 public function _construct()
 {
     parent::_construct();
     $this->_init('advancednewsletter/automanagement');
 }
示例#14
0
 public function _construct()
 {
     Mage_Rule_Model_Rule::_construct();
     $this->_init('points/rule');
     $this->setIdFieldName('rule_id');
 }
示例#15
0
 protected function _afterSave()
 {
     parent::_afterSave();
 }
示例#16
0
 protected function _construct()
 {
     parent::_construct();
     $this->_init('xtento_orderexport/profile');
 }
示例#17
0
 protected function _afterSave()
 {
     if ($storeId = $this->getStoreId()) {
         $storeAttributes = $this->getStoreAttributes();
         foreach ($storeAttributes as $attribute) {
             $attributeValue = Mage::getModel('affiliateplusprogram/value')->loadAttributeValue($this->getId(), $storeId, $attribute);
             if ($this->getData($attribute . '_in_store')) {
                 try {
                     $attributeValue->setValue($this->getData($attribute . '_value'))->save();
                 } catch (Exception $e) {
                 }
             } elseif ($attributeValue && $attributeValue->getId()) {
                 try {
                     $attributeValue->delete();
                 } catch (Exception $e) {
                 }
             }
         }
     }
     if (is_string($this->getData('tier_commission'))) {
         $this->setData('tier_commission', unserialize($this->getData('tier_commission')));
     }
     if (is_string($this->getData('sec_tier_commission'))) {
         $this->setData('sec_tier_commission', unserialize($this->getData('sec_tier_commission')));
     }
     return parent::_afterSave();
 }
示例#18
0
 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();
 }
示例#19
0
 /**
  * @param Mage_Rule_Model_Rule $rule
  * @return string
  */
 public function formatCustomerGroups($rule)
 {
     $names = array();
     $ids = $rule->getCustomerGroupIds();
     foreach ($ids as $id) {
         $names[] = $this->_customerGroupNames[$id];
     }
     return implode(', ', $names);
 }
 protected function _afterLoad()
 {
     parent::_afterLoad();
     $paymentMethodsIds = $this->_getData('payment_methods_ids');
     if (is_string($paymentMethodsIds)) {
         $this->setPaymentMethodsIds(explode(',', $paymentMethodsIds));
     }
     $shippingMethodsIds = $this->_getData('shipping_methods_ids');
     if (is_string($shippingMethodsIds)) {
         $this->setShippingMethodsIds(explode(',', $shippingMethodsIds));
     }
 }
示例#21
0
 /**
  * Retrieve Actions instance wrapper
  *
  * @return Enterprise_TargetRule_Model_Actions_Condition_Combine
  */
 public function getActions()
 {
     return parent::getActions();
 }
示例#22
0
 public function _construct()
 {
     parent::_construct();
     $this->_init('customerreward/rule');
     $this->setIdFieldName('rule_id');
 }
示例#23
0
文件: Rule.php 项目: rcclaudrey/dev
 protected function _beforeDelete()
 {
     $this->_setWebsiteIds();
     return parent::_beforeDelete();
 }
示例#24
0
 /**
  * Validate rule before delete
  *
  * @param Mage_Rule_Model_Rule $model
  * @return void
  */
 public function ruleDeleteBefore($model)
 {
     $originalWebsiteIds = $model->getOrigData('website_ids');
     if (!$this->_role->hasExclusiveAccess($originalWebsiteIds)) {
         $this->_throwDelete();
     }
 }
 protected function _validateAddress($quote)
 {
     $ret = false;
     foreach ($quote->getAllAddresses() as $address) {
         $this->_initAddress($address, $quote);
         if (parent::validate($address)) {
             $ret = true;
             break;
         }
     }
     return $ret;
 }
 /**
  * Save rula labels after rule save
  *
  * @return Mage_SalesRule_Model_Rule
  */
 protected function _afterSave()
 {
     if ($this->hasStoreLabels()) {
         $this->_getResource()->saveStoreLabels($this->getId(), $this->getStoreLabels());
     }
     return parent::_afterSave();
 }
 /**
  * Process rule related data after rule save
  *
  * @return Mage_CatalogRule_Model_Rule
  */
 protected function _afterSave()
 {
     $this->_getResource()->updateRuleProductData($this);
     parent::_afterSave();
 }
示例#28
0
 /**
  * Getter for rule actions collection
  *
  * @return Mage_Rule_Model_Action_Collection
  */
 public function getActionsInstance()
 {
     return parent::getActionsInstance();
 }
 public function _construct()
 {
     parent::_construct();
     $this->_init('awafptc/rule');
 }
示例#30
0
 public function _construct()
 {
     parent::_construct();
     $this->_init('customercredit/product');
 }