Mage_Tax_Model_Mysql4_Calculation_Rule_Collection Class Reference

Inheritance diagram for Mage_Tax_Model_Mysql4_Calculation_Rule_Collection:

Mage_Core_Model_Mysql4_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 joinCalculationData ($alias)
 addProductTaxClassesToResult ()
 addCustomerTaxClassesToResult ()
 addRatesToResult ()
 setClassTypeFilter ($type, $id)

Protected Member Functions

 _construct ()
 _add ($itemTable, $primaryJoinField, $secondaryJoinField, $titleField, $dataField)


Detailed Description

Tax rule collection

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 33 of file Collection.php.


Member Function Documentation

_add ( itemTable,
primaryJoinField,
secondaryJoinField,
titleField,
dataField 
) [protected]

Definition at line 46 of file Collection.php.

00047     {
00048         $children = array();
00049         foreach ($this as $rule) {
00050             $children[$rule->getId()] = array();
00051         }
00052         if (!empty($children)) {
00053             $select = $this->getConnection()->select()
00054                 ->from(array('calculation'=>$this->getTable('tax_calculation')), array('calculation.tax_calculation_rule_id'))
00055                 ->join(
00056                     array('item'=>$this->getTable($itemTable)),
00057                     "item.{$secondaryJoinField} = calculation.{$primaryJoinField}",
00058                     array("item.{$titleField}"))
00059                 ->where('calculation.tax_calculation_rule_id IN (?)', array_keys($children))
00060                 ->distinct(true);
00061 
00062             $data = $this->getConnection()->fetchAll($select);
00063             foreach ($data as $row) {
00064                $children[$row['tax_calculation_rule_id']][] = $row[$titleField];
00065             }
00066         }
00067         foreach ($this as $rule) {
00068             if (isset($children[$rule->getId()])) {
00069                 $rule->setData($dataField, $children[$rule->getId()]);
00070             }
00071         }
00072         return $this;
00073     }

_construct (  )  [protected]

Initialization here

Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.

Definition at line 35 of file Collection.php.

00036     {
00037         $this->_init('tax/calculation_rule');
00038     }

addCustomerTaxClassesToResult (  ) 

Definition at line 79 of file Collection.php.

00080     {
00081         return $this->_add('tax_class', 'customer_tax_class_id', 'class_id', 'class_name', 'customer_tax_classes');
00082     }

addProductTaxClassesToResult (  ) 

Definition at line 75 of file Collection.php.

00076     {
00077         return $this->_add('tax_class', 'product_tax_class_id', 'class_id', 'class_name', 'product_tax_classes');
00078     }

addRatesToResult (  ) 

Definition at line 83 of file Collection.php.

00084     {
00085         return $this->_add('tax_calculation_rate', 'tax_calculation_rate_id', 'tax_calculation_rate_id', 'code', 'tax_rates');
00086     }

joinCalculationData ( alias  ) 

Definition at line 40 of file Collection.php.

00041     {
00042         $this->getSelect()->joinLeft(array($alias=>$this->getTable('tax_calculation')), "main_table.tax_calculation_rule_id = {$alias}.tax_calculation_rule_id", array());
00043         $this->getSelect()->group('main_table.tax_calculation_rule_id');
00044     }

setClassTypeFilter ( type,
id 
)

Definition at line 88 of file Collection.php.

00089     {
00090         switch ($type) {
00091             case 'PRODUCT':
00092                 $field = 'cd.product_tax_class_id';
00093                 break;
00094             case 'CUSTOMER':
00095                 $field = 'cd.customer_tax_class_id';
00096                 break;
00097             default:
00098                 Mage::throwException('Invalid type supplied');
00099         }
00100 
00101         $this->joinCalculationData('cd');
00102         $this->addFieldToFilter($field, $id);
00103         return $this;
00104     }


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

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