当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Rule_Model_Condition_Abstract类代码示例

本文整理汇总了PHP中Mage_Rule_Model_Condition_Abstract的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Rule_Model_Condition_Abstract类的具体用法?PHP Mage_Rule_Model_Condition_Abstract怎么用?PHP Mage_Rule_Model_Condition_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mage_Rule_Model_Condition_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadArray

 /**
  * Overwrite parent method to add new operators
  *
  * @param array $arr
  *
  * @return MatheusGontijo_EasyShippingRules_Model_Rule_Condition_Product|Mage_CatalogRule_Model_Rule_Condition_Product
  */
 public function loadArray($arr)
 {
     $isBetweenOperator = isset($arr['operator']) && in_array($arr['operator'], array('><', '<>'));
     if (isset($arr['value']) && $isBetweenOperator) {
         $valueExploded = explode('-', $arr['value']);
         if (isset($valueExploded[0]) && isset($valueExploded[1])) {
             $arr['value'] = Mage::app()->getLocale()->getNumber($valueExploded[0]) . '-' . Mage::app()->getLocale()->getNumber($valueExploded[1]);
             return Mage_Rule_Model_Condition_Abstract::loadArray($arr);
         } else {
             $arr['value'] = '';
         }
     }
     return parent::loadArray($arr);
 }
开发者ID:xiaoguizhidao,项目名称:easy-shipping-rules,代码行数:21,代码来源:Product.php

示例2: getNewChildSelectOptions

 public function getNewChildSelectOptions()
 {
     $productCondition = Mage::getModel('easyshippingrules/rule_condition_product');
     $productAttributes = $productCondition->loadAttributeOptions()->getAttributeOption();
     $pAttributes = array();
     $cAttributes = array();
     foreach ($productAttributes as $code => $label) {
         if (strpos($code, 'quote_item_') === 0) {
             $cAttributes[] = array('value' => 'easyshippingrules/rule_condition_product|' . $code, 'label' => $label);
         } else {
             $pAttributes[] = array('value' => 'easyshippingrules/rule_condition_product|' . $code, 'label' => $label);
         }
     }
     $conditions = Mage_Rule_Model_Condition_Abstract::getNewChildSelectOptions();
     $conditions = array_merge_recursive($conditions, array(array('label' => Mage::helper('easyshippingrules')->__('Cart Item Attribute'), 'value' => $cAttributes), array('label' => Mage::helper('easyshippingrules')->__('Product Attribute'), 'value' => $pAttributes)));
     return $conditions;
 }
开发者ID:xiaoguizhidao,项目名称:easy-shipping-rules,代码行数:17,代码来源:Found.php

示例3: _validateProduct

 /**
  * Validate product
  *
  * @param Varien_Object $object
  * @return bool
  */
 protected function _validateProduct($object)
 {
     return Mage_Rule_Model_Condition_Abstract::validate($object);
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:10,代码来源:Product.php

示例4: getDefaultOperatorOptions

 /**
  * Default operator options getter
  * Provides all possible operator options
  *
  * @return array
  */
 public function getDefaultOperatorOptions()
 {
     if (null === $this->_defaultOperatorOptions) {
         $this->_defaultOperatorOptions = parent::getDefaultOperatorOptions();
         $this->_defaultOperatorOptions['[]'] = Mage::helper('rule')->__('contains');
         $this->_defaultOperatorOptions['![]'] = Mage::helper('rule')->__('does not contains');
     }
     return $this->_defaultOperatorOptions;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:15,代码来源:Abstract.php

示例5: getDefaultOperatorInputByType

 /**
  * Customize default operator input by type mapper for some types
  * @return array
  */
 public function getDefaultOperatorInputByType()
 {
     if (null === $this->_defaultOperatorInputByType) {
         parent::getDefaultOperatorInputByType();
         $this->_defaultOperatorInputByType['numeric'] = array('==', '!=', '>=', '>', '<=', '<');
         $this->_defaultOperatorInputByType['string'] = array('==', '!=', '{}', '!{}');
     }
     return $this->_defaultOperatorInputByType;
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:13,代码来源:Abstract.php

示例6: validate

 /**
  * Validate Address Rule Condition
  *
  * @param Varien_Object|Mage_Sales_Model_Order|Mage_Sales_Model_Quote $object
  * @return bool
  */
 public function validate(Varien_Object $object)
 {
     /* @var $object Mage_Sales_Model_Order|Mage_Sales_Model_Quote */
     //Get infos from billing address
     $toValidate = new Varien_Object();
     $customer_id = $object->getCustomerId();
     $orders_count = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_id', $customer_id)->count();
     $toValidate->setOrdersCount($orders_count);
     $toValidate->setCustomerIsGuest(is_null($object->getCustomerIsGuest()) ? 0 : $object->getCustomerIsGuest());
     $toValidate->setDiffAddresses($this->_addressesesAreDifferent($object));
     $toValidate->setCustomerGroup($object->getCustomerGroupId());
     return parent::validate($toValidate);
 }
开发者ID:hipay,项目名称:hipay-fullservice-sdk-magento1,代码行数:19,代码来源:Customer.php

示例7: getDefaultOperatorOptions

 /**
  * Overwrite parent method to update label
  *
  * @return array
  */
 public function getDefaultOperatorOptions()
 {
     if (!$this->_defaultOperatorOptions) {
         $defaultOperatorOptions = parent::getDefaultOperatorOptions();
         if (isset($defaultOperatorOptions['=='])) {
             $defaultOperatorOptions['=='] = Mage::helper('easyshippingrules')->__('is valid');
         }
         if (isset($defaultOperatorOptions['!='])) {
             $defaultOperatorOptions['!='] = Mage::helper('easyshippingrules')->__('is not valid');
         }
         $this->_defaultOperatorOptions = $defaultOperatorOptions;
     }
     return $this->_defaultOperatorOptions;
 }
开发者ID:xiaoguizhidao,项目名称:easy-shipping-rules,代码行数:19,代码来源:Programmaticmethod.php

示例8: validateAttribute

 public function validateAttribute($validatedValue)
 {
     $op = $this->getOperatorForValidate();
     $value = $this->getValueParsed();
     if ($op == '{}' || $op == '!{}') {
         $result = false;
         if (is_array($validatedValue) && is_scalar($value)) {
             foreach ($validatedValue as $item) {
                 if (stripos($item, $value) !== false) {
                     $result = true;
                     break;
                 }
             }
         }
         if ($op == '!{}') {
             $result = !$result;
         }
         return $result;
     }
     return parent::validateAttribute($validatedValue);
 }
开发者ID:ashfaqphplhr,项目名称:artificiallawnsforturf,代码行数:21,代码来源:Abstract.php

示例9: validate

 /**
  * Validate product attrbute value for condition
  *
  * @param  Varien_Object $object Object
  * @return boolean True/False
  */
 public function validate(Varien_Object $object)
 {
     $attrCode = $this->getAttribute();
     if ('category_ids' == $attrCode) {
         return $this->validateAttribute($object->getAvailableInCategories());
     } elseif (!isset($this->_entityAttributeValues[$object->getId()])) {
         $attr = $object->getResource()->getAttribute($attrCode);
         if ($attr && $attr->getBackendType() == 'datetime' && !is_int($this->getValue())) {
             $this->setValue(strtotime($this->getValue()));
             $value = strtotime($object->getData($attrCode));
             return $this->validateAttribute($value);
         }
         if ($attr && $attr->getFrontendInput() == 'multiselect') {
             $value = $object->getData($attrCode);
             $value = strlen($value) ? explode(',', $value) : array();
             return $this->validateAttribute($value);
         }
         return parent::validate($object);
     } else {
         $result = false;
         $oldAttrValue = $object->hasData($attrCode) ? $object->getData($attrCode) : null;
         foreach ($this->_entityAttributeValues[$object->getId()] as $storeId => $value) {
             $object->setData($attrCode, $value);
             $result = parent::validate($object);
             if ($result) {
                 break;
             }
         }
         if (null === $oldAttrValue) {
             $object->unsetData($attrCode);
         } else {
             $object->setData($attrCode, $oldAttrValue);
         }
         return (bool) $result;
     }
 }
开发者ID:nhp,项目名称:firegento-dynamiccategory,代码行数:42,代码来源:Product.php

示例10: validate

 /**
  * Validate Address Rule Condition
  *
  * @param Varien_Object $object
  *
  * @return bool
  */
 public function validate(Varien_Object $object)
 {
     $objectForParent = $object;
     $adressAttributes = array('weight', 'shipping_method', 'postcode', 'region', 'region_id', 'country_id');
     if ($this->getAttribute() == 'method') {
         $objectForParent = $object->getPayment();
     }
     if (in_array($this->getAttribute(), $adressAttributes)) {
         if ($object->isVirtual()) {
             $objectForParent = $object->getBillingAddress();
         } else {
             $objectForParent = $object->getShippingAddress();
         }
         try {
             $countryId = $objectForParent->getCountryId();
             if (!is_null($countryId)) {
                 $numOfCountryRegions = count(Mage::getModel('directory/country')->loadByCode($countryId)->getRegions()->getData());
                 if ($numOfCountryRegions == 0) {
                     $objectForParent->setRegionId('0');
                 }
             }
         } catch (Exception $e) {
             Mage::log('Exception: ' . $e->getMessage() . ' in ' . __CLASS__ . ' on line ' . __LINE__);
         }
     }
     return parent::validate($objectForParent);
 }
开发者ID:HPTTeam,项目名称:hackathon,代码行数:34,代码来源:Address.php

示例11: validate

 /**
  * Validate Address Rule Condition
  *
  * @param Varien_Object $object
  * @return bool
  */
 public function validate(Varien_Object $object)
 {
     $address = $object;
     if (!$address instanceof Mage_Sales_Model_Quote_Address) {
         if ($object->getQuote()->isVirtual()) {
             $address = $object->getQuote()->getBillingAddress();
         } else {
             $address = $object->getQuote()->getShippingAddress();
         }
     }
     return parent::validate($address);
 }
开发者ID:joebushi,项目名称:magento-mirror,代码行数:18,代码来源:Address.php

示例12: validateAttribute

 public function validateAttribute($validatedValue)
 {
     if (is_object($validatedValue)) {
         return false;
     }
     if (is_string($validatedValue)) {
         $validatedValue = strtoupper($validatedValue);
     }
     /**
      * Condition attribute value
      */
     $value = $this->getValueParsed();
     if (is_string($value)) {
         $value = strtoupper($value);
     }
     /**
      * Comparison operator
      */
     $op = $this->getOperatorForValidate();
     // if operator requires array and it is not, or on opposite, return false
     if ($this->_isArrayOperatorType() xor is_array($value)) {
         return false;
     }
     $result = false;
     switch ($op) {
         case '{%':
             if (!is_scalar($validatedValue)) {
                 return false;
             } else {
                 $result = substr($validatedValue, 0, strlen($value)) == $value;
             }
             break;
         case '%}':
             if (!is_scalar($validatedValue)) {
                 return false;
             } else {
                 $result = substr($validatedValue, -strlen($value)) == $value;
             }
             break;
         default:
             return parent::validateAttribute($validatedValue);
             break;
     }
     return $result;
 }
开发者ID:rcclaudrey,项目名称:dev,代码行数:45,代码来源:Address.php

示例13: validate

 /**
  * Validate Address Rule Condition
  *
  * @param Varien_Object $object
  * @return bool
  */
 public function validate(Varien_Object $object)
 {
     $address = $object;
     if (!$address instanceof Mage_Sales_Model_Quote_Address) {
         if ($object->getQuote()->isVirtual()) {
             $address = $object->getQuote()->getBillingAddress();
         } else {
             $address = $object->getQuote()->getShippingAddress();
         }
     }
     if ('payment_method' == $this->getAttribute() && !$address->hasPaymentMethod()) {
         $address->setPaymentMethod($object->getQuote()->getPayment()->getMethod());
     }
     return parent::validate($address);
 }
开发者ID:rbrown,项目名称:magento-gifts,代码行数:21,代码来源:Address.php

示例14: validate

 public function validate(Varien_Object $object)
 {
     $customerId = $object->getQuote()->getCustomerId();
     if ($customerId) {
         $customer = Mage::getModel('customer/customer')->load($customerId);
         $datas = $customer->getData();
         return parent::validate($datas);
     }
     return false;
     //if ($object instanceof Mage_Sales_Model_Order && $order->getId())
     /*
             if ($datas = $object->getData()){
                 return parent::validate($object);
             } else {
                 return false;
             }*/
 }
开发者ID:ntnhan220488,项目名称:ggm,代码行数:17,代码来源:Params.php

示例15: validate

 public function validate(Varien_Object $order)
 {
     if ($this->getAttribute() == 'method') {
         return parent::validate($order->getPayment());
     }
     if (in_array($this->getAttribute(), array('postcode', 'region', 'region_id', 'country_id'))) {
         if ($order->getIsVirtual()) {
             $address = $order->getBillingAddress();
         } else {
             $address = $order->getShippingAddress();
         }
         $countryId = $address->getCountryId();
         if (!is_null($countryId)) {
             try {
                 $regions = Mage::getModel('directory/country')->loadByCode($countryId)->getRegions()->getData();
             } catch (Exception $e) {
                 Mage::log($e->getMessage());
             }
             if (count($regions) == 0) {
                 $address->setRegionId('0');
             }
         }
         return parent::validate($address);
     }
     return parent::validate($order);
 }
开发者ID:sshegde123,项目名称:wmp8,代码行数:26,代码来源:Order.php


注:本文中的Mage_Rule_Model_Condition_Abstract类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。