Question

I have created a set of custom variable in my sales_flat_quote_item and sales_flat_order_item and saved custom field values into sales_flat_quote_item using the observer <checkout_cart_product_add_after> as below,

        <checkout_cart_product_add_after>
            <observers>
                <ucs_catalogorder_checkout_cart_product_add_after>
                    <type>model</type>
                    <class>Ucs_CatalogOrder_Model_Observer</class>
                    <method>checkoutCartProductAddAfter</method>
                </ucs_catalogorder_checkout_cart_product_add_after>
            </observers>
        </checkout_cart_product_add_after>

Then added the same into sales_flat_order_item using below code snippet

    <fieldsets>
       <sales_convert_quote_item>
           <card_wallet_amount>
               <to_order_item>*</to_order_item>
           </card_wallet_amount>
           <card_handling_charges>
               <to_order_item>*</to_order_item>
           </card_handling_charges>
           <user_preferred_delivery_mode>
               <to_order_item>*</to_order_item>
           </user_preferred_delivery_mode>
           <message_title>
               <to_order_item>*</to_order_item>
           </message_title>
           <message_description>
               <to_order_item>*</to_order_item>
           </message_description>
           <card_library_image>
               <to_order_item>*</to_order_item>
           </card_library_image>
           <wrapper_library_image>
               <to_order_item>*</to_order_item>
           </wrapper_library_image>
       </sales_convert_quote_item>
   </fieldsets>

But after completing the payment process the same has not been saved into either sales_flat_order or sales_flat_quote

Was it helpful?

Solution

You'll need to decide whether you want that information at the entire order level or at the order line-item level.

Both these tables, sales_flat_order_item and sales_flat_order, serve different purposes in context of an order. The way you created the attribute, information will be saved at the order-item level, like SKU of a product. It is specific to every line item of an order, but can not be stored at the entire order level.

If you are dealing with information that is scoped at the entire order level, like shipping method of order, only then you'll need to save that info into sales_flat_order table. Magento will not do this automatically, you'll need to do that yourself. It will be done the same way you created attribute for order item. You'll just need to observe the different event for that, sales_model_service_quote_submit_after might be a good choice.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top