Magento – Custom field in sales_flat_quote_item not being transferred to sales_flat_order_item

ordersquote

Both tables have the same custom field added to it.
I have an observer listening for "sales_quote_item_set_product". I'm setting the field like this:

$quoteItem->setData("custom_code", "TEST");

If I go to sales_flat_quote_item, I can see the custom_code field being populated with "TEST". Once I place the order, the corresponding entry in sales_flat_order_item still has custom_code==null.

Do I need to listen for another event? Is there one like sales_order_item_set_product? I searched around and didn't see anything.

Best Answer

I figured it out. I needed to add this to my extensions config.xml file:

    <fieldsets>
        <sales_convert_quote_item>
            <custom_attribute>
                <to_order_item>*</to_order_item>
            </custom_attribute>
        </sales_convert_quote_item>
        <sales_convert_order_item>
            <custom_attribute>
                <to_quote_item>*</to_quote_item>
            </custom_attribute>
        </sales_convert_order_item>
    </fieldsets>
Related Topic