Mage_SalesRule_Model_Rule_Condition_Product_Subselect Class Reference

Inheritance diagram for Mage_SalesRule_Model_Rule_Condition_Product_Subselect:

Mage_SalesRule_Model_Rule_Condition_Product_Combine Mage_Rule_Model_Condition_Combine Mage_Rule_Model_Condition_Abstract Varien_Object Mage_Rule_Model_Condition_Interface

List of all members.

Public Member Functions

 __construct ()
 loadArray ($arr, $key='conditions')
 asXml ($containerKey='conditions', $itemKey='condition')
 loadAttributeOptions ()
 loadOperatorOptions ()
 getValueElementType ()
 asHtml ()
 validate (Varien_Object $object)


Detailed Description

Definition at line 28 of file Subselect.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes

Reimplemented from Mage_SalesRule_Model_Rule_Condition_Product_Combine.

Definition at line 31 of file Subselect.php.

00032     {
00033         parent::__construct();
00034         $this->setType('salesrule/rule_condition_product_subselect')
00035             ->setValue(null);
00036     }


Member Function Documentation

asHtml (  ) 

Reimplemented from Mage_Rule_Model_Condition_Combine.

Definition at line 95 of file Subselect.php.

00096     {
00097         $html = $this->getTypeElement()->getHtml().
00098             Mage::helper('salesrule')->__("If %s %s %s for a subselection of items in cart matching %s of these conditions:",
00099               $this->getAttributeElement()->getHtml(),
00100               $this->getOperatorElement()->getHtml(),
00101               $this->getValueElement()->getHtml(),
00102               $this->getAggregatorElement()->getHtml()
00103            );
00104            if ($this->getId()!='1') {
00105                $html.= $this->getRemoveLinkHtml();
00106            }
00107         return $html;
00108     }

asXml ( containerKey = 'conditions',
itemKey = 'condition' 
)

Reimplemented from Mage_Rule_Model_Condition_Combine.

Definition at line 46 of file Subselect.php.

00047     {
00048         $xml .= '<attribute>'.$this->getAttribute().'</attribute>'
00049             .'<operator>'.$this->getOperator().'</operator>'
00050             .parent::asXml($containerKey, $itemKey);
00051         return $xml;
00052     }

getValueElementType (  ) 

Value element type will define renderer for condition value element

See also:
Varien_Data_Form_Element
Returns:
string

Reimplemented from Mage_Rule_Model_Condition_Combine.

Definition at line 90 of file Subselect.php.

00091     {
00092         return 'text';
00093     }

loadArray ( arr,
key = 'conditions' 
)

Reimplemented from Mage_Rule_Model_Condition_Combine.

Definition at line 38 of file Subselect.php.

00039     {
00040         $this->setAttribute($arr['attribute']);
00041         $this->setOperator($arr['operator']);
00042         parent::loadArray($arr, $key);
00043         return $this;
00044     }

loadAttributeOptions (  ) 

Reimplemented from Mage_Rule_Model_Condition_Abstract.

Definition at line 65 of file Subselect.php.

00066     {
00067         $hlp = Mage::helper('salesrule');
00068         $this->setAttributeOption(array(
00069             'qty'  => $hlp->__('total quantity'),
00070             'row_total'  => $hlp->__('total amount'),
00071         ));
00072         return $this;
00073     }

loadOperatorOptions (  ) 

Reimplemented from Mage_Rule_Model_Condition_Abstract.

Definition at line 75 of file Subselect.php.

00076     {
00077         $this->setOperatorOption(array(
00078             '=='  => Mage::helper('rule')->__('is'),
00079             '!='  => Mage::helper('rule')->__('is not'),
00080             '>='  => Mage::helper('rule')->__('equals or greater than'),
00081             '<='  => Mage::helper('rule')->__('equals or less than'),
00082             '>'   => Mage::helper('rule')->__('greater than'),
00083             '<'   => Mage::helper('rule')->__('less than'),
00084             '()'  => Mage::helper('rule')->__('is one of'),
00085             '!()' => Mage::helper('rule')->__('is not one of'),
00086         ));
00087         return $this;
00088     }

validate ( Varien_Object object  ) 

validate

Parameters:
Varien_Object $object Quote
Returns:
boolean

Reimplemented from Mage_Rule_Model_Condition_Combine.

Definition at line 116 of file Subselect.php.

00117     {
00118         if (!$this->getConditions()) {
00119             return false;
00120         }
00121 
00122 //        $value = $this->getValue();
00123 //        $aggregatorArr = explode('/', $this->getAggregator());
00124 //        $this->setValue((int)$aggregatorArr[0])->setAggregator($aggregatorArr[1]);
00125 
00126         $attr = $this->getAttribute();
00127         $total = 0;
00128         foreach ($object->getQuote()->getAllItems() as $item) {
00129             if (parent::validate($item)) {
00130                 $total += $item->getData($attr);
00131             }
00132         }
00133 //        $this->setAggregator(join('/', $aggregatorArr))->setValue($value);
00134 
00135         return $this->validateAttribute($total);
00136     }


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