Stevenrkn
Stevenrkn

Reputation: 1

Magento Custom Order Attribute

I am trying to add a custom attribute field to the sales_flat_order table in the database for Magento 1.8+. Do I need to create a New Admin theme?

<?php
$installer = $this;
$installer->startSetup();

$installer->addAttribute("order", "my_custom_input_field", array("type"=>"varchar"));
$installer->addAttribute("quote", "my_custom_input_field", array("type"=>"varchar"));
$installer->endSetup(); 

Upvotes: 0

Views: 554

Answers (1)

PvdL
PvdL

Reputation: 1593

Try this:

$installer->addAttribute(Mage_Sales_Model_Order::ENTITY, 'THIS_IS_THE_CODE', array(
    'group'         => 'General',
    'type'          => 'varchar',
    'default'       => '0',
    'input'         => 'text',
    'label'         => 'My pretty pretty label',
    'source'        => '',
    'visible'       => true,
    'required'      => false,
    'visible_on_front' => false,
    'user_defined'  =>  false
));

$installer->addAttribute(Mage_Sales_Model_Quote::ENTITY, 'THIS_IS_THE_CODE', array(
    'group'         => 'General',
    'type'          => 'varchar',
    'default'       => '0',
    'input'         => 'text',
    'label'         => 'My pretty pretty label',
    'source'        => '',
    'visible'       => true,
    'required'      => false,
    'visible_on_front' => false,
    'user_defined'  =>  false
));

Upvotes: 1

Related Questions