Create a custom order attribute in Magento

I’ve run into a few posts about this thing but none of them was working out of the box so I took all the info and glued them together so…

if you’ve to create a custom attribute for a Magento order but you don’t have a module (and its installer script) simply create a php file in the project’s root with this code:

$installer = new Mage_Sales_Model_Mysql4_Setup;
$attribute  = array(
        'type'          => 'text',
        'backend_type'  => 'text',
        'frontend_input' => 'text',
        'is_user_defined' => true,
        'label'         => 'Your attribute label',
        'visible'       => true,
        'required'      => false,
        'user_defined'  => false,   
        'searchable'    => false,
        'filterable'    => false,
        'comparable'    => false,
        'default'       => ''
$installer->addAttribute('order', 'your_attribute_code', $attribute);

This attribute is a “text” and it’s made not to be visible but just to use it as a container for some data you may need in your custom development, more info may come in comments if you need.

4 thoughts on “Create a custom order attribute in Magento

  1. martin

    nice tutorial
    too much time was lost too find the best solution for my problems with customers attributes.
    i read much information about magento and some modifications.
    but one day my old friend advise me a great solution for me.
    he advised me amasty’s extension customer attributes. and it is really works perfect.
    your are free to read about that extension

    you can ask some questions about extension to amasty.

Leave a Reply

Your email address will not be published. Required fields are marked *