Public Member Functions | |
setEnv (Mage_Rule_Model_Environment $env=null) | |
getEnv () | |
addItem (Varien_Object $rule) | |
setActiveFilter () | |
process () | |
Protected Member Functions | |
_construct () | |
_afterLoad () | |
Protected Attributes | |
$_env |
Definition at line 34 of file Collection.php.
_afterLoad | ( | ) | [protected] |
Reimplemented from Varien_Data_Collection_Db.
Definition at line 145 of file Collection.php.
00146 { 00147 $this->walk('afterLoad'); 00148 }
_construct | ( | ) | [protected] |
Initialization here
Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.
Definition at line 43 of file Collection.php.
00044 { 00045 $this->_init('rule/rule'); 00046 }
addItem | ( | Varien_Object $ | rule | ) |
Overload default addItem method to set environment for the rules
Mage_Rule_Model_Abstract | $rule |
Reimplemented from Varien_Data_Collection.
Definition at line 97 of file Collection.php.
00098 { 00099 $rule->setEnv($this->getEnv())->setIsCollectionValidated(true); 00100 parent::addItem($rule); 00101 return $this; 00102 }
getEnv | ( | ) |
Retrieve environment for the rules in collection
Definition at line 82 of file Collection.php.
00083 { 00084 if (!$this->_env) { 00085 $this->_env = Mage::getModel('core/rule_environment'); 00086 $this->_env->collect(); 00087 } 00088 return $this->_env; 00089 }
process | ( | ) |
Process the quote with all the rules in collection
Definition at line 133 of file Collection.php.
00134 { 00135 $rules = $this->getItems(); 00136 foreach ($rules as $rule) { 00137 $rule->process(); 00138 if ($rule->getStopProcessingRules()) { 00139 break; 00140 } 00141 } 00142 return $this; 00143 }
setActiveFilter | ( | ) |
Set filter for the collection based on the environment
Definition at line 109 of file Collection.php.
00110 { 00111 $e = $this->getEnv()->getData(); 00112 00113 $this->_select->where("is_active=1"); 00114 00115 if (!empty($e['now'])) { 00116 if (!is_numeric($e['now'])) { 00117 $e['now'] = strtotime($e['now']); 00118 } 00119 $now = date("Y-m-d H:i:s", $e['now']); 00120 } else { 00121 $now = date("Y-m-d H:i:s"); 00122 } 00123 $this->_select->where("start_at<='$now' and expire_at>='$now'"); 00124 00125 return $this; 00126 }
setEnv | ( | Mage_Rule_Model_Environment $ | env = null |
) |
Initialize resource collection variables
Example: Set environment for all rules in collection
Mage_Rule_Model_Environment | $env |
Definition at line 71 of file Collection.php.
$_env [protected] |
Definition at line 41 of file Collection.php.