/** * Adding attribute to entity * * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute * @return Mage_Eav_Model_Entity_Abstract */ public function addAttribute(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { $attribute->setEntity($this); $attributeCode = $attribute->getAttributeCode(); $this->_attributesByCode[$attributeCode] = $attribute; if ($attribute->isStatic()) { $this->_staticAttributes[$attributeCode] = $attribute; } else { $this->_attributesById[$attribute->getId()] = $attribute; $this->_attributesByTable[$attribute->getBackendTable()][$attributeCode] = $attribute; } return $this; }
/** * Get attribute type for upcoming validation. * * @param Mage_Eav_Model_Entity_Attribute_Abstract|Mage_Eav_Model_Entity_Attribute $attribute * @return string */ public static function getAttributeType(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { if ($attribute->usesSource()) { return $attribute->getFrontendInput() == 'multiselect' ? 'multiselect' : 'select'; } elseif ($attribute->isStatic()) { return $attribute->getFrontendInput() == 'date' ? 'datetime' : 'varchar'; } else { return $attribute->getBackendType(); } }