Public Member Functions | |
deleteEntity () | |
getBackendTypeByInput ($type) | |
getDefaultValueByInput ($type) | |
getAttributeCodesByFrontendType ($type) | |
Public Attributes | |
const | CACHE_TAG = 'EAV_ATTRIBUTE' |
Protected Member Functions | |
_getDefaultBackendModel () | |
_getDefaultFrontendModel () | |
_getDefaultSourceModel () | |
_beforeSave () | |
_afterSave () | |
_beforeDelete () | |
Protected Attributes | |
$_eventPrefix = 'eav_entity_attribute' | |
$_eventObject = 'attribute' | |
$_cacheTag = 'EAV_ATTRIBUTE' |
Definition at line 35 of file Attribute.php.
_afterSave | ( | ) | [protected] |
Processing object after save data
Reimplemented from Mage_Core_Model_Abstract.
Reimplemented in Mage_Catalog_Model_Entity_Attribute.
Definition at line 146 of file Attribute.php.
00147 { 00148 $this->_getResource()->saveInSetIncluding($this); 00149 00150 return parent::_afterSave(); 00151 }
_beforeDelete | ( | ) | [protected] |
Processing object before delete data
Reimplemented from Mage_Core_Model_Abstract.
Definition at line 153 of file Attribute.php.
00154 { 00155 if ($this->_getResource()->isUsedBySuperProducts($this)) { 00156 Mage::throwException(Mage::helper('eav')->__('Attribute used in configurable products.')); 00157 } 00158 return parent::_beforeDelete(); 00159 }
_beforeSave | ( | ) | [protected] |
Processing object before save data
Reimplemented from Mage_Core_Model_Abstract.
Reimplemented in Mage_Catalog_Model_Entity_Attribute.
Definition at line 96 of file Attribute.php.
00097 { 00098 // prevent overriding product data 00099 if (isset($this->_data['attribute_code']) 00100 && Mage::getModel('catalog/product')->isReservedAttribute($this)) { 00101 Mage::throwException(Mage::helper('eav')->__('The attribute code \'%s\' is reserved by system. Please, try another attribute code.', $this->_data['attribute_code'])); 00102 } 00103 00104 // prevent changing attribute scope, if used in configurable products 00105 if (isset($this->_origData['is_global'])) { 00106 if (!isset($this->_data['is_global'])) { 00107 Mage::throwException('0_o'); 00108 } 00109 if (($this->_data['is_global'] != $this->_origData['is_global']) 00110 && $this->_getResource()->isUsedBySuperProducts($this)) { 00111 Mage::throwException(Mage::helper('eav')->__('Scope must not be changed, because the attribute is used in configurable products.')); 00112 } 00113 } 00114 00115 if ($this->getBackendType() == 'datetime') { 00116 if (!$this->getBackendModel()) { 00117 $this->setBackendModel('eav/entity_attribute_backend_datetime'); 00118 } 00119 00120 if (!$this->getFrontendModel()) { 00121 $this->setFrontendModel('eav/entity_attribute_frontend_datetime'); 00122 } 00123 00124 // save default date value as timestamp 00125 if ($defaultValue = $this->getDefaultValue()) { 00126 $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); 00127 $this->setDefaultValue(Mage::app()->getLocale()->date($defaultValue, $format, null, false)->toValue()); 00128 } 00129 } 00130 00131 if ($this->getBackendType() == 'gallery') { 00132 if (!$this->getBackendModel()) { 00133 $this->setBackendModel('eav/entity_attribute_backend_media'); 00134 } 00135 } 00136 00137 if ($this->getFrontendInput() == 'price') { 00138 if (!$this->getBackendModel()) { 00139 $this->setBackendModel('catalog/product_attribute_backend_price'); 00140 } 00141 } 00142 00143 return parent::_beforeSave(); 00144 }
_getDefaultBackendModel | ( | ) | [protected] |
Reimplemented from Mage_Eav_Model_Entity_Attribute_Abstract.
Definition at line 56 of file Attribute.php.
00057 { 00058 switch ($this->getAttributeCode()) { 00059 case 'created_at': 00060 return 'eav/entity_attribute_backend_time_created'; 00061 00062 case 'updated_at': 00063 return 'eav/entity_attribute_backend_time_updated'; 00064 00065 case 'store_id': 00066 return 'eav/entity_attribute_backend_store'; 00067 00068 case 'increment_id': 00069 return 'eav/entity_attribute_backend_increment'; 00070 } 00071 00072 00073 00074 return parent::_getDefaultBackendModel(); 00075 }
_getDefaultFrontendModel | ( | ) | [protected] |
Reimplemented from Mage_Eav_Model_Entity_Attribute_Abstract.
Definition at line 77 of file Attribute.php.
00078 { 00079 return parent::_getDefaultFrontendModel(); 00080 }
_getDefaultSourceModel | ( | ) | [protected] |
Reimplemented from Mage_Eav_Model_Entity_Attribute_Abstract.
Reimplemented in Mage_Catalog_Model_Resource_Eav_Attribute.
Definition at line 82 of file Attribute.php.
00083 { 00084 switch ($this->getAttributeCode()) { 00085 case 'store_id': 00086 return 'eav/entity_attribute_source_store'; 00087 } 00088 return parent::_getDefaultSourceModel(); 00089 }
deleteEntity | ( | ) |
Definition at line 91 of file Attribute.php.
00092 { 00093 return $this->_getResource()->deleteEntity($this); 00094 }
getAttributeCodesByFrontendType | ( | $ | type | ) |
Definition at line 246 of file Attribute.php.
00247 { 00248 return $this->getResource()->getAttributeCodesByFrontendType($type); 00249 }
getBackendTypeByInput | ( | $ | type | ) |
Detect backend storage type using frontend input type
string | $type frontend_input field value |
Definition at line 167 of file Attribute.php.
00168 { 00169 switch ($type) { 00170 case 'text': 00171 case 'gallery': 00172 case 'media_image': 00173 case 'multiselect': 00174 return 'varchar'; 00175 00176 case 'image': 00177 case 'textarea': 00178 return 'text'; 00179 00180 case 'date': 00181 return 'datetime'; 00182 00183 case 'select': 00184 case 'boolean': 00185 return 'int'; 00186 00187 00188 case 'price': 00189 return 'decimal'; 00190 /* 00191 default: 00192 Mage::dispatchEvent('eav_attribute_get_backend_type_by_input', array('model'=>$this, 'type'=>$type)); 00193 if ($this->hasBackendTypeByInput()) { 00194 return $this->getData('backend_type_by_input'); 00195 } 00196 Mage::throwException('Unknown frontend input type'); 00197 */ 00198 } 00199 }
getDefaultValueByInput | ( | $ | type | ) |
Detect default value using frontend input type
string | $type frontend_input field name |
Definition at line 207 of file Attribute.php.
00208 { 00209 $field = ''; 00210 switch ($type) { 00211 case 'select': 00212 case 'gallery': 00213 case 'media_image': 00214 case 'multiselect': 00215 return ''; 00216 00217 case 'text': 00218 case 'price': 00219 case 'image': 00220 $field = 'default_value_text'; 00221 break; 00222 00223 case 'textarea': 00224 $field = 'default_value_textarea'; 00225 break; 00226 00227 case 'date': 00228 $field = 'default_value_date'; 00229 break; 00230 00231 case 'boolean': 00232 $field = 'default_value_yesno'; 00233 break; 00234 /* 00235 default: 00236 Mage::dispatchEvent('eav_attribute_get_default_value_by_input', array('model'=>$this, 'type'=>$type)); 00237 if ($this->hasBackendTypeByInput()) { 00238 return $this->getData('backend_type_by_input'); 00239 } 00240 Mage::throwException('Unknown frontend input type'); 00241 */ 00242 } 00243 00244 return $field; 00245 }
$_cacheTag = 'EAV_ATTRIBUTE' [protected] |
$_eventObject = 'attribute' [protected] |
Reimplemented from Mage_Core_Model_Abstract.
Reimplemented in Mage_Catalog_Model_Entity_Attribute.
Definition at line 51 of file Attribute.php.
$_eventPrefix = 'eav_entity_attribute' [protected] |
Reimplemented from Mage_Core_Model_Abstract.
Reimplemented in Mage_Catalog_Model_Entity_Attribute.
Definition at line 42 of file Attribute.php.
const CACHE_TAG = 'EAV_ATTRIBUTE' |
Definition at line 53 of file Attribute.php.