コード例 #1
0
ファイル: Abstract.php プロジェクト: test3metizsoft/test
 /**
  * Prepare value for save
  *
  * @param mixed $value
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @return mixed
  */
 protected function _prepareValueForSave($value, Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
 {
     if ($attribute->getBackendType() == 'decimal') {
         return Mage::app()->getLocale()->getNumber($value);
     }
     $backendTable = $attribute->getBackendTable();
     if (!isset(self::$_attributeBackendTables[$backendTable])) {
         self::$_attributeBackendTables[$backendTable] = $this->_getReadAdapter()->describeTable($backendTable);
     }
     $describe = self::$_attributeBackendTables[$backendTable];
     return $this->_getReadAdapter()->prepareColumnValue($describe['value'], $value);
 }
コード例 #2
0
 /**
  * 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;
 }