Mage_SalesRule_Model_Rule_Condition_Product_Found Class Reference

Inheritance diagram for Mage_SalesRule_Model_Rule_Condition_Product_Found:

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 ()
 loadValueOptions ()
 asHtml ()
 validate (Varien_Object $object)


Detailed Description

Definition at line 28 of file Found.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 Found.php.

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


Member Function Documentation

asHtml (  ) 

Reimplemented from Mage_Rule_Model_Condition_Combine.

Definition at line 46 of file Found.php.

00047     {
00048         $html = $this->getTypeElement()->getHtml().
00049             Mage::helper('salesrule')->__("If an item is %s in the cart with %s of these conditions true:",
00050             $this->getValueElement()->getHtml(), $this->getAggregatorElement()->getHtml());
00051         if ($this->getId()!='1') {
00052             $html.= $this->getRemoveLinkHtml();
00053         }
00054         return $html;
00055     }

loadValueOptions (  ) 

Reimplemented from Mage_Rule_Model_Condition_Combine.

Definition at line 37 of file Found.php.

00038     {
00039         $this->setValueOption(array(
00040             1=>'FOUND',
00041             0=>'NOT FOUND',
00042         ));
00043         return $this;
00044     }

validate ( Varien_Object object  ) 

validate

Parameters:
Varien_Object $object Quote
Returns:
boolean

Reimplemented from Mage_Rule_Model_Condition_Combine.

Definition at line 63 of file Found.php.

00064     {
00065         $all = $this->getAggregator()==='all';
00066         $true = (bool)$this->getValue();
00067         $found = false;
00068         foreach ($object->getAllItems() as $item) {
00069             $found = $all ? true : false;
00070             foreach ($this->getConditions() as $cond) {
00071                 $validated = $cond->validate($item);
00072                 if ($all && !$validated) {
00073                     $found = false;
00074                     break;
00075                 } elseif (!$all && $validated) {
00076                     $found = true;
00077                     break 2;
00078                 }
00079             }
00080             if ($found && $true) {
00081                 break;
00082             }
00083         }
00084         if ($found && $true) {
00085             // found an item and we're looking for existing one
00086 
00087             return true;
00088         } elseif (!$found && !$true) {
00089             // not found and we're making sure it doesn't exist
00090             return true;
00091         }
00092         return false;
00093     }


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