Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Setting length of new attribute using Mage_Sales_Model_Resource_Setup::addAttribute
 
pcreact
Jr. Member
 
Total Posts:  4
Joined:  2013-02-20
 

Hello,

I’m adding a couple of custom attributes to order_address and quote_address. I want them to be of type ‘decimal’ with length ‘11,8’.

I’ve followed the addAttribute call through to _getAttributeColumnDefinition:

switch ($data['type']{
            
case 'timestamp':
                
$type Varien_Db_Ddl_Table::TYPE_TIMESTAMP;
                break;
            case 
'datetime':
                
$type Varien_Db_Ddl_Table::TYPE_DATETIME;
                break;
            case 
'decimal':
                
$type Varien_Db_Ddl_Table::TYPE_DECIMAL;
                
$length '12,4';
                break;
            case 
'int':
                
$type Varien_Db_Ddl_Table::TYPE_INTEGER;
                break;
            case 
'text':
                
$type Varien_Db_Ddl_Table::TYPE_TEXT;
                
$length 65536;
                break;
            case 
'char':
            case 
'varchar':
                
$type Varien_Db_Ddl_Table::TYPE_TEXT;
                
$length 255;
                break;
        
}
        
if ($type !== null{
            $data[
'type'$type;
            
$data['length'$length;
        
}

It looks like decimal length is automatically set to 12,4 and there doesn’t seem to be any way to over-ride this. I was wondering why you aren’t able to pass “length” with your data array, or if there is another way for me to do this without hacking the core?

Thanks,

Phil.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top