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
00033
00034 class Mage_Catalog_Model_Resource_Eav_Attribute extends Mage_Eav_Model_Entity_Attribute
00035 {
00036 const SCOPE_STORE = 0;
00037 const SCOPE_GLOBAL = 1;
00038 const SCOPE_WEBSITE = 2;
00039
00040
00041
00042
00043
00044
00045 static protected $_labels = null;
00046
00047
00048
00049
00050
00051
00052 public function isScopeGlobal()
00053 {
00054 return $this->getIsGlobal() == self::SCOPE_GLOBAL;
00055 }
00056
00057
00058
00059
00060
00061
00062 public function isScopeWebsite()
00063 {
00064 return $this->getIsGlobal() == self::SCOPE_WEBSITE;
00065 }
00066
00067
00068
00069
00070
00071
00072 public function isScopeStore()
00073 {
00074 return !$this->isScopeGlobal() && !$this->isScopeWebsite();
00075 }
00076
00077
00078
00079
00080
00081
00082 public function getStoreId()
00083 {
00084 if ($dataObject = $this->getDataObject()) {
00085 return $dataObject->getStoreId();
00086 }
00087 return $this->getData('store_id');
00088 }
00089
00090
00091
00092
00093
00094
00095
00096 public function getApplyTo()
00097 {
00098 if ($this->getData('apply_to')) {
00099 return explode(',', $this->getData('apply_to'));
00100 } else {
00101 return array();
00102 }
00103 }
00104
00105
00106
00107
00108
00109
00110 public function getSourceModel()
00111 {
00112 $model = $this->getData('source_model');
00113 if (empty($model)) {
00114 if ($this->getBackendType() == 'int' && $this->getFrontendInput() == 'select') {
00115 return 'eav/entity_attribute_source_table';
00116 }
00117 }
00118 return $model;
00119 }
00120
00121
00122
00123
00124
00125
00126 public function isAllowedForRuleCondition()
00127 {
00128 $allowedInputTypes = array('text', 'multiselect', 'textarea', 'date', 'datetime', 'select', 'boolean', 'price');
00129 return $this->getIsVisible() && in_array($this->getFrontendInput(), $allowedInputTypes);
00130 }
00131
00132
00133
00134
00135
00136
00137 public function getFrontendLabel()
00138 {
00139 return $this->_getData('frontend_label');
00140 }
00141
00142
00143
00144
00145
00146
00147
00148 protected function _getLabelForStore()
00149 {
00150 return $this->getFrontendLabel();
00151
00152
00153 }
00154
00155
00156
00157
00158
00159
00160
00161 public static function initLabels($storeId = null)
00162 {
00163 if (is_null(self::$_labels)) {
00164 if (is_null($storeId)) {
00165 $storeId = Mage::app()->getStore()->getId();
00166 }
00167 $attributeLabels = array();
00168 $attributes = Mage::getResourceSingleton('catalog/product')->getAttributesByCode();
00169 foreach ($attributes as $attribute) {
00170 if (strlen($attribute->getData('frontend_label')) > 0) {
00171 $attributeLabels[] = $attribute->getData('frontend_label');
00172 }
00173 }
00174
00175 self::$_labels = Mage::app()->getTranslator()->getResource()->getTranslationArrayByStrings($attributeLabels, $storeId);
00176 }
00177 }
00178
00179
00180
00181
00182
00183
00184 public function _getDefaultSourceModel()
00185 {
00186 return 'eav/entity_attribute_source_table';
00187 }
00188 }