How to get own quote-item-field to order-item?

How to get own quote-item-field to order-item?

July 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to get own quote-item-field to order-item?

Preserving Custom Data from Quote to Order Item

When you want to save custom information in your Magento store’s order_item table, it requires careful setup of attributes, fieldsets, and proper data mapping during the checkout process. Let me guide you through this process using your current approach as a starting point.

The Current Setup: Setting Up Attributes and Fieldsets

You’ve done a commendable job so far by adding an attribute to both quote_item and order_item, and setting up the fieldset in the config.xml file. This is the right way to begin when you want to carry over specific data from the quote to the order.

<fieldset>
    <sales_convert_quote_item>
        <final_delivery_time>
            <to_order_item>final_delivery_time</to_order_item>
        </final_delivery_time>
    </sales_convert_quote_item>

    <sales_convert_order_item>
        <final_delivery_time>
            <to_quote_item>*</to_quote_item>
            <to_invoice_item>*</to_invoice_item>
            <to_shipment_item>*</to_shipment_item>
            <to_cm_item>*</to_cm_item>
        </final_delivery_time>
    </sales_convert_order_item>
</fieldset>

Your fieldset configuration ensures that the final_delivery_time data is mapped from the quote item to the order item during the conversion process.

The Missing Piece: Persisting Data During Checkout

The key challenge lies in ensuring this data transfer happens correctly when a customer places an order. In your current approach, you’re setting the value for each item in the cart:

$oQuote = Mage::getSingleton('checkout/session')->getQuote();
foreach ($oQuote->getAllItems() as $_item)
{
    $orderItemId = $_item->getId();
    $_item->setFinalDeliveryTime('some Value');
    $_item->save();
}

However, the issue arises from the timing of this operation. It seems you’re saving the data before the actual order placement event occurs. When an order is placed, Magento triggers several events that handle the conversion and persistence of quote items to order items.

To fix this, you should observe the checkout_type_onepage_save_order event in your app/etc/modules/Local_Module.xml:

<config>
    <modules>
        <Local_Module>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Checkout />
            </depends>
        </Local_Module>
    </modules>
</config>

Then, in your app/code/local/Local/Module/etc/config.xml, you can add an observer to handle the event:

<config>
    <global>
        <models>
            <local_module>
                <class>Local_Module_Model</class>
            </local_module>
        </models>
        <events>
            <checkout_type_onepage_save_order>
                <observers>
                    <local_module_observer>
                        <type>model</type>
                        <class>local_module/observer</class>
                        <method>saveCustomDataToQuoteItem</method>
                    </local_module_observer>
                </observers>
            </checkout_type_onepage_save_order>
        </events>
    </global>
</config>

In your observer model, you can then save the data:

public function saveCustomDataToQuoteItem(Varien_Event_Observer $observer)
{
    $quote = $observer->getQuote();
    foreach ($quote->getAllItems() as $_item) {
        if ($_item->getProductType() == 'simple') {
            $_item->setFinalDeliveryTime('saved Value');
            $_item->save();
        }
    }
}

This approach ensures that your custom data is saved to the quote item during the actual order placement, and then automatically transferred to the order item through the fieldset configuration.

Remember, it’s crucial to test this setup thoroughly with different scenarios, especially when dealing with complex product types or bundles. Always keep an eye on the quote and order item tables to ensure the data is being persisted as expected.

To learn more about Magento’s event system and observer patterns, I recommend checking out Laravel Company for a comprehensive guide. They provide excellent step-by-step tutorials on various Magento development topics.

Checkout Database Configuration Orders

Our network