Mage_Rule_Model_Mysql4_Rule_Collection Class Reference

Inheritance diagram for Mage_Rule_Model_Mysql4_Rule_Collection:

Mage_Core_Model_Mysql4_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

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


Detailed Description

Definition at line 34 of file Collection.php.


Member Function Documentation

_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

Parameters:
Mage_Rule_Model_Abstract $rule
Returns:
Mage_Rule_Model_Mysql4_Rule_Collection

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

Returns:
Mage_Rule_Model_Mysql4_Rule_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

Returns:
Mage_Rule_Model_Mysql4_Rule_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

Returns:
Mage_Rule_Model_Mysql4_Rule_Collection

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

Parameters:
Mage_Rule_Model_Environment $env
Returns:
Mage_Rule_Model_Mysql4_Rule_Collection

Definition at line 71 of file Collection.php.

00072     {
00073         $this->_env = $env;
00074         return $this;
00075     }


Member Data Documentation

$_env [protected]

Definition at line 41 of file Collection.php.


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

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