/**
  * 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)
 {
     $type = $attribute->getBackendType();
     if (($type == 'int' || $type == 'decimal' || $type == 'datetime') && $value === '') {
         $value = null;
     }
     return parent::_prepareValueForSave($value, $attribute);
 }
예제 #2
0
 /**
  * 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);
 }
예제 #3
0
파일: Import.php 프로젝트: nemphys/magento2
 /**
  * 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();
     }
 }
예제 #4
0
 /**
  * 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);
     }
     return $value;
 }
예제 #5
0
 /**
  * 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)
 {
     $type = $attribute->getBackendType();
     if (($type == 'int' || $type == 'decimal' || $type == 'datetime') && $value === '') {
         return null;
     }
     if ($type == 'decimal') {
         return Mage::app()->getLocale()->getNumber($value);
     }
     return $value;
 }
예제 #6
0
 /**
  * Ensure values are OK for numeric attributes before saving them
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute Attribute to prepare the value for
  * @param mixed                                    $value     Value to be saved
  *
  * @return mixed The value ready for save
  */
 protected function _prepareValueForDocumentSave($attribute, $value)
 {
     if (is_object($value)) {
         $value = (string) $value;
     }
     if ($value != '') {
         $type = strtolower($attribute->getBackendType());
         // Handle numeric cast to float
         $value = $this->_prepareTableValueForSave($value, $attribute->getBackendType());
         if ($type == "int") {
             // Ensure int storage is correct
             $value = (int) $value;
         }
     }
     return $value;
 }