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 class Mage_Tax_Model_Class_Source_Product extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
00029 {
00030 public function getAllOptions($withEmpty = false)
00031 {
00032 if (is_null($this->_options)) {
00033 $this->_options = Mage::getResourceModel('tax/class_collection')
00034 ->addFieldToFilter('class_type', 'PRODUCT')
00035 ->load()
00036 ->toOptionArray();
00037 }
00038
00039 $options = $this->_options;
00040 array_unshift($options, array('value'=>'0', 'label'=>Mage::helper('tax')->__('None')));
00041 if ($withEmpty) {
00042 array_unshift($options, array('value'=>'', 'label'=>Mage::helper('tax')->__('-- Please Select --')));
00043 }
00044 return $options;
00045 }
00046
00047
00048
00049
00050
00051
00052
00053 public function getOptionText($value)
00054 {
00055 $options = $this->getAllOptions(false);
00056
00057 foreach ($options as $item) {
00058 if ($item['value'] == $value) {
00059 return $item['label'];
00060 }
00061 }
00062 return false;
00063 }
00064
00065 public function toOptionArray()
00066 {
00067 return $this->getAllOptions();
00068 }
00069
00070
00071
00072
00073
00074
00075 public function getFlatColums()
00076 {
00077 $columns = array();
00078 $columns[$this->getAttribute()->getAttributeCode()] = array(
00079 'type' => 'int',
00080 'unsigned' => false,
00081 'is_null' => true,
00082 'default' => null,
00083 'extra' => null
00084 );
00085 return $columns;
00086 }
00087
00088
00089
00090
00091
00092
00093
00094 public function getFlatUpdateSelect($store)
00095 {
00096 return Mage::getResourceModel('eav/entity_attribute_option')
00097 ->getFlatUpdateSelect($this->getAttribute(), $store, false);
00098 }
00099 }