コード例 #1
0
ファイル: Abstract.php プロジェクト: hyhoocchan/mage-local
 /**
  * Saves a new attribute
  *
  * @param Mage_Customer_Model_Attribute $attribute
  * @return Enterprise_Customer_Model_Resource_Sales_Abstract
  */
 public function saveNewAttribute(Mage_Customer_Model_Attribute $attribute)
 {
     $backendType = $attribute->getBackendType();
     if ($backendType == Mage_Customer_Model_Attribute::TYPE_STATIC) {
         return $this;
     }
     switch ($backendType) {
         case 'datetime':
             $definition = array('type' => Varien_Db_Ddl_Table::TYPE_DATE);
             break;
         case 'decimal':
             $definition = array('type' => Varien_Db_Ddl_Table::TYPE_DECIMAL, 'length' => 12, 4);
             break;
         case 'int':
             $definition = array('type' => Varien_Db_Ddl_Table::TYPE_INTEGER);
             break;
         case 'text':
             $definition = array('type' => Varien_Db_Ddl_Table::TYPE_TEXT);
             break;
         case 'varchar':
             $definition = array('type' => Varien_Db_Ddl_Table::TYPE_TEXT, 'length' => 255);
             break;
         default:
             return $this;
     }
     $columnName = $this->_getColumnName($attribute);
     $definition['comment'] = ucwords(str_replace('_', ' ', $columnName));
     $this->_getWriteAdapter()->addColumn($this->getMainTable(), $columnName, $definition);
     return $this;
 }
コード例 #2
0
ファイル: Abstract.php プロジェクト: jpbender/mage_virtual
 /**
  * Saves a new attribute
  *
  * @param Mage_Customer_Model_Attribute $attribute
  * @return Enterprise_Customer_Model_Mysql4_Sales_Abstract
  */
 public function saveNewAttribute(Mage_Customer_Model_Attribute $attribute)
 {
     $backendType = $attribute->getBackendType();
     if ($backendType == Mage_Customer_Model_Attribute::TYPE_STATIC) {
         return $this;
     }
     switch ($backendType) {
         case 'datetime':
             $defination = "DATE NULL DEFAULT NULL";
             break;
         case 'decimal':
             $defination = "DECIMAL(12,4) DEFAULT NULL";
             break;
         case 'int':
             $defination = "INT(11) DEFAULT NULL";
             break;
         case 'text':
             $defination = "TEXT DEFAULT NULL";
             break;
         case 'varchar':
             $defination = "VARCHAR(255) DEFAULT NULL";
             break;
         default:
             return $this;
     }
     $this->_getWriteAdapter()->addColumn($this->getMainTable(), $this->_getColumnName($attribute), $defination);
     return $this;
 }