00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class Mage_Customer_Model_Entity_Group_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
00033 {
00034 protected function _construct()
00035 {
00036 $this->_init('customer/group');
00037 }
00038
00039 public function setTaxGroupFilter($classId)
00040 {
00041 $taxClassGroupTable = Mage::getSingleton('core/resource')->getTableName('tax/tax_class_group');
00042 $this->_select->joinLeft($taxClassGroupTable, "{$taxClassGroupTable}.class_group_id=main_table.customer_group_id");
00043 $this->_select->where("{$taxClassGroupTable}.class_parent_id = ?", $classId);
00044 return $this;
00045 }
00046
00047 public function setIgnoreIdFilter($indexes)
00048 {
00049 if( !count($indexes) > 0 ) {
00050 return $this;
00051 }
00052 $this->_select->where('main_table.customer_group_id NOT IN(?)', $indexes);
00053 return $this;
00054 }
00055
00056 public function setRealGroupsFilter()
00057 {
00058 $this->addFieldToFilter('customer_group_id', array('gt'=>0));
00059 return $this;
00060 }
00061
00062 public function addTaxClass()
00063 {
00064 $taxClassTable = Mage::getSingleton('core/resource')->getTableName('tax/tax_class');
00065 $this->_select->joinLeft($taxClassTable, "main_table.tax_class_id = {$taxClassTable}.class_id");
00066
00067 return $this;
00068 }
00069
00070 public function toOptionArray()
00071 {
00072 return parent::_toOptionArray('customer_group_id', 'customer_group_code');
00073 }
00074 public function toOptionHash()
00075 {
00076 return parent::_toOptionHash('customer_group_id', 'customer_group_code');
00077 }
00078 }