title: How to convert quote attribute to order in Magento?
body: <p>I've spent two days on this, I feel like I've tried everything,still I keep hitting the wall.</p>
  
  <p>I've got two attributes (module_job_id, module_channel_id) that I'd love to add to quote and order. Where I managed to get is that the quote attributes work fine, I can see them stored in database and they can be retrieved fine.</p>
  
  <p>The only thing left is moving the values across from quote to order. What am I doing wrong?</p>
  
  <p>Here's my module config file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;config&gt;
  
      &lt;modules&gt;
          &lt;Company_Module&gt;
              &lt;version&gt;0.1.9&lt;/version&gt;
          &lt;/Company_Module&gt;
      &lt;/modules&gt;
  
      &lt;global&gt;
          &lt;fieldsets&gt;
              &lt;sales_convert_quote&gt;
                  &lt;module_job_id&gt;
                      &lt;to_order&gt;*&lt;/to_order&gt;
                  &lt;/module_job_id&gt;
  
                  &lt;module_channel_id&gt;
                      &lt;to_order&gt;*&lt;/to_order&gt;
                  &lt;/module_channel_id&gt;
              &lt;/sales_convert_quote&gt;
          &lt;/fieldsets&gt;
  
          &lt;resources&gt;
              &lt;company_module&gt;
                  &lt;setup&gt;
                      &lt;module&gt;Company_Module&lt;/module&gt;
                      &lt;class&gt;Mage_Sales_Model_Mysql4_Setup&lt;/class&gt;
                  &lt;/setup&gt;
                  &lt;connection&gt;
                      &lt;use&gt;core_setup&lt;/use&gt;
                  &lt;/connection&gt;
              &lt;/company_module&gt;
          &lt;/resources&gt;
  
      &lt;/global&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>The installation file sql/company_module/mysql4-install-0.1.0.php:</p>
  
  <pre><code>&lt;?php
      $installer = $this;
      $installer-&gt;startSetup();
  
      $installer-&gt;getConnection()-&gt;addColumn($installer-&gt;getTable('sales/quote'), 'module_job_id',
          'VARCHAR(255) NULL DEFAULT NULL');
      $installer-&gt;getConnection()-&gt;addColumn($installer-&gt;getTable('sales/quote'), 'module_channel_id',
          'VARCHAR(255) NULL DEFAULT NULL');
  
      $installer-&gt;getConnection()-&gt;addColumn($installer-&gt;getTable('sales/order'), 'module_job_id',
          'VARCHAR(255) NULL DEFAULT NULL');
      $installer-&gt;getConnection()-&gt;addColumn($installer-&gt;getTable('sales/order'), 'module_channel_id',
          'VARCHAR(255) NULL DEFAULT NULL');
  
      $installer-&gt;addAttribute('order', 'module_job_id', array('type' =&gt; 'varchar'));
      $installer-&gt;addAttribute('quote', 'module_job_id', array('type' =&gt; 'varchar'));
  
      $installer-&gt;addAttribute('order', 'module_channel_id', array('type' =&gt; 'varchar'));
      $installer-&gt;addAttribute('quote', 'module_channel_id', array('type' =&gt; 'varchar'));
  
      $installer-&gt;endSetup();
  </code></pre>
  
  <p>I've tried all possible combinations of addAttribute and addColumns in the installation file. The result is that I've got both attributes as columns in both sales_flat_quote and sales_flat_order. However, none of the attributes is in eav_attribute. I'm not sure if that's OK.</p>
  
  <p>One more thing I tried is setting the order attribute values explicitly in the sales_convert_quote_to_order observer. This didn't work:</p>
  
  <pre><code>public function salesConvertQuoteToOrder($observer)
  {
      $order = $observer-&gt;getEvent()-&gt;getOrder();
  
      $order-&gt;setModuleJobId('123');
      $order-&gt;setModuleChannelId('456');
  }
  </code></pre>
  
  <p>I don't know if it's important, but these are the entity types on my system (only order, no quote...):</p>
  
  <pre><code>mysql&gt; SELECT entity_type_id, entity_type_code FROM eav_entity_type;
  +----------------+------------------+
  | entity_type_id | entity_type_code |
  +----------------+------------------+
  |              3 | catalog_category |
  |              4 | catalog_product  |
  |              7 | creditmemo       |
  |              1 | customer         |
  |              2 | customer_address |
  |              6 | invoice          |
  |              5 | order            |
  |              8 | shipment         |
  +----------------+------------------+
  </code></pre>
  
  <p>Also, eav_entity is empty. I hope that's OK, too.</p>
  
  <pre><code>mysql&gt; select * from eav_entity;
  Empty set (0.00 sec)
  </code></pre>
  
  <p>This is on Magento 1.6.2.0. Thanks heaps!</p>