Mage_SalesRule_Model_Mysql4_Rule_Collection Class Reference

Inheritance diagram for Mage_SalesRule_Model_Mysql4_Rule_Collection:

Mage_Core_Model_Mysql4_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 setValidationFilter ($websiteId, $customerGroupId, $couponCode='', $now=null)
 addWebsiteFilter ($websiteIds)

Protected Member Functions

 _construct ()


Detailed Description

Definition at line 28 of file Collection.php.


Member Function Documentation

_construct (  )  [protected]

Initialization here

Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.

Definition at line 30 of file Collection.php.

00031     {
00032         parent::_construct();
00033         $this->_init('salesrule/rule');
00034     }

addWebsiteFilter ( websiteIds  ) 

Filter collection by specified website IDs

Parameters:
int|array $websiteIds
Returns:
Mage_CatalogRule_Model_Mysql4_Rule_Collection

Definition at line 65 of file Collection.php.

00066     {
00067         if (!is_array($websiteIds)) {
00068             $websiteIds = array($websiteIds);
00069         }
00070         $parts = array();
00071         foreach ($websiteIds as $websiteId) {
00072             $parts[] = $this->getConnection()->quoteInto('FIND_IN_SET(?, main_table.website_ids)', $websiteId);
00073         }
00074         if ($parts) {
00075             $this->getSelect()->where(new Zend_Db_Expr(implode(' OR ', $parts)));
00076         }
00077         return $this;
00078     }

setValidationFilter ( websiteId,
customerGroupId,
couponCode = '',
now = null 
)

Definition at line 36 of file Collection.php.

00037     {
00038         if (is_null($now)) {
00039             $now = Mage::getModel('core/date')->date('Y-m-d');
00040         }
00041 
00042         $this->addBindParam('coupon_code', $couponCode);
00043         $this->getSelect()->where('is_active=1');
00044         $this->getSelect()->where('find_in_set(?, website_ids)', (int)$websiteId);
00045         $this->getSelect()->where('find_in_set(?, customer_group_ids)', (int)$customerGroupId);
00046         if (empty($couponCode)) {
00047             $this->getSelect()->where("coupon_code is null or coupon_code=''");
00048         }
00049         else {
00050             $this->getSelect()->where("coupon_code is null or coupon_code='' or coupon_code=:coupon_code");
00051         }
00052         $this->getSelect()->where('from_date is null or from_date<=?', $now);
00053         $this->getSelect()->where('to_date is null or to_date>=?', $now);
00054         $this->getSelect()->order('sort_order');
00055 
00056         return $this;
00057     }


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