title: Save custom attribute in order
body: <p>I'm having trouble getting and setting a custom attribute in the order.</p>
  
  <p>I have the following SQL script:</p>
  
  <pre><code>&lt;?php
  
  $installer = $this;
  $installer-&gt;startSetup();
  
  $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
  
  $attribute = array(
      'position'          =&gt; 1,
      'type'              =&gt; 'text',
      'input'             =&gt; 'varchar',
      'label'             =&gt; 'My Order Field',
      'global'            =&gt; 1,
      'visible'           =&gt; 1,
      'required'          =&gt; 0,
      'user_defined'      =&gt; 1,
      'searchable'        =&gt; 0,
      'filterable'        =&gt; 0,
      'comparable'        =&gt; 0,
      'visible_on_front'  =&gt; 1,
      'visible_in_advanced_search' =&gt; 0,
      'unique'            =&gt; 0,
      'is_configurable'   =&gt; 0,
      'position'          =&gt; 1,
  );
  
  $setup-&gt;addAttribute('order', 'my_order_field', $attribute);
  
  $installer-&gt;endSetup();
  </code></pre>
  
  <p>I can see the attribute in the eav table after running this.</p>
  
  <p>I've then setup a observer that runs when a new order has been saved which i've also confirmed is running (with die() statements).</p>
  
  <p>I've now removed those die statements and changed the order save code to this:</p>
  
  <pre><code>$event = $observer-&gt;getEvent();
  $order = $event-&gt;getOrder();
  $order-&gt;setMyOrderField('Hello');
  </code></pre>
  
  <p>And in my admin backend section I've added a row to retrieve the data:</p>
  
  <pre><code>    &lt;tr&gt;
          &lt;td class="label"&gt;&lt;label&gt;&lt;?php echo Mage::helper('sales')-&gt;__('My Order Field') ?&gt;&lt;/label&gt;&lt;/td&gt;
          &lt;td class="value"&gt;&lt;strong&gt;&lt;?php echo $_order-&gt;getMyOrderField(); ?&gt;&lt;/strong&gt;&lt;/td&gt;
      &lt;/tr&gt;
  </code></pre>
  
  <p>However when I put a fresh order through nothing appears, can anyone tell me what I'm doing wrong in terms of saving data to my custom attribute?</p>
  
  <p>Thanks</p>