Mage_SalesRule_Model_Rule Class Reference

Inheritance diagram for Mage_SalesRule_Model_Rule:

Mage_Rule_Model_Rule Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 getConditionsInstance ()
 getActionsInstance ()
 toString ($format='')
 loadPost (array $rule)
 toArray (array $arrAttributes=array())
 getResourceCollection ()

Public Attributes

const FREE_SHIPPING_ITEM = 1
const FREE_SHIPPING_ADDRESS = 2

Protected Member Functions

 _construct ()
 _beforeSave ()
 _beforeDelete ()


Detailed Description

Definition at line 28 of file Rule.php.


Member Function Documentation

_beforeDelete (  )  [protected]

Processing object before delete data

Returns:
Mage_Core_Model_Abstract

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 55 of file Rule.php.

00056     {
00057         if ($coupon = $this->getCouponCode()) {
00058             Mage::app()->cleanCache('salesrule_coupon_'.$coupon);
00059         }
00060         parent::_beforeDelete();
00061     }

_beforeSave (  )  [protected]

Processing object before save data

Returns:
Mage_Core_Model_Abstract

Reimplemented from Mage_Rule_Model_Rule.

Definition at line 40 of file Rule.php.

00041     {
00042         if($coupon = $this->getCouponCode()) {
00043             $this->getResource()->addUniqueField(array(
00044                 'field' => 'coupon_code',
00045                 'title' => Mage::helper('salesRule')->__('Coupon with the same code')
00046             ));
00047             Mage::app()->cleanCache('salesrule_coupon_'.md5($coupon));
00048         } else {
00049             $this->getResource()->resetUniqueField();
00050         }
00051         return parent::_beforeSave();
00052     }

_construct (  )  [protected]

Enter description here...

Reimplemented from Mage_Rule_Model_Rule.

Definition at line 33 of file Rule.php.

00034     {
00035         parent::_construct();
00036         $this->_init('salesrule/rule');
00037         $this->setIdFieldName('rule_id');
00038     }

getActionsInstance (  ) 

Reimplemented from Mage_Rule_Model_Rule.

Definition at line 68 of file Rule.php.

00069     {
00070         return Mage::getModel('salesrule/rule_condition_product_combine');
00071     }

getConditionsInstance (  ) 

Reimplemented from Mage_Rule_Model_Rule.

Definition at line 63 of file Rule.php.

00064     {
00065         return Mage::getModel('salesrule/rule_condition_combine');
00066     }

getResourceCollection (  ) 

Get collection instance

Returns:
object

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 149 of file Rule.php.

00150     {
00151         return Mage::getResourceModel('salesrule/rule_collection');
00152     }

loadPost ( array rule  ) 

Reimplemented from Mage_Rule_Model_Rule.

Definition at line 86 of file Rule.php.

00087     {
00088         $arr = $this->_convertFlatToRecursive($rule);
00089         if (isset($arr['conditions'])) {
00090             $this->getConditions()->loadArray($arr['conditions'][1]);
00091         }
00092         if (isset($arr['actions'])) {
00093             $this->getActions()->loadArray($arr['actions'][1], 'actions');
00094         }
00095 
00096         return $this;
00097     }

toArray ( array arrAttributes = array()  ) 

Returns rule as an array for admin interface

Output example: array( 'name'=>'Example rule', 'conditions'=>{condition_combine.toArray} 'actions'=>{action_collection.toArray} )

Returns:
array

Reimplemented from Varien_Object.

Definition at line 111 of file Rule.php.

00112     {
00113         $out = parent::toArray($arrAttributes);
00114         $out['customer_registered'] = $this->getCustomerRegistered();
00115         $out['customer_new_buyer'] = $this->getCustomerNewBuyer();
00116 
00117         return $out;
00118     }

toString ( format = ''  ) 

Public wrapper for __toString

Will use $format as an template and substitute {{key}} for attributes

Parameters:
string $format
Returns:
string

Reimplemented from Varien_Object.

Definition at line 73 of file Rule.php.

00074     {
00075         $str = Mage::helper('salesrule')->__("Name: %s", $this->getName()) ."\n"
00076              . Mage::helper('salesrule')->__("Start at: %s", $this->getStartAt()) ."\n"
00077              . Mage::helper('salesrule')->__("Expire at: %s", $this->getExpireAt()) ."\n"
00078              . Mage::helper('salesrule')->__("Customer registered: %s", $this->getCustomerRegistered()) ."\n"
00079              . Mage::helper('salesrule')->__("Customer is new buyer: %s", $this->getCustomerNewBuyer()) ."\n"
00080              . Mage::helper('salesrule')->__("Description: %s", $this->getDescription()) ."\n\n"
00081              . $this->getConditions()->toStringRecursive() ."\n\n"
00082              . $this->getActions()->toStringRecursive() ."\n\n";
00083         return $str;
00084     }


Member Data Documentation

Definition at line 31 of file Rule.php.

const FREE_SHIPPING_ITEM = 1

Definition at line 30 of file Rule.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:50 2009 for Magento by  doxygen 1.5.8