Magento 2

Convert from quote item to order item using fieldset

 
There is custom field in quote_item table same as sales_order_item both column name and type are same.
 
I want to convert quote_item table to sales_order_item table. so I have used fieldset.xml to convert those data,
 
1) create etc/fieldset.xml file 
 
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:DataObject/etc/fieldset.xsd">
<scope id="global">
    <fieldset id="quote_convert_item">
        <field name="customcolumn1">
            <aspect name="to_order_item" />
        </field>
        <field name="customcolumn2">
            <aspect name="to_order_item" />
        </field>
    </fieldset>
</scope>

</config> 

 

2) You need to use the following code with your fieldset.xml.

 

Just place one line code in your magento 2 root dir vendor\magento\module-quote\Model\Quote\Item\ToOrderItem.php

 

Search the line:

 

$orderItem = $this->orderItemFactory->create();

Place the code after the searched line:

 

$this->objectCopyService->copyFieldsetToTarget('quote_convert_item', 'to_order_item', $item, $orderItem); 

0 Bình luận

Trở về
  • Magento plug-ins
  • Magento plug-ins

    Magento2 gave very good concept called Plugin   we can do what ever after and before core function and also we have...

  • HOW TO CREATE MENU IN MAGENTO 2 ADMIN
  • HOW TO CREATE MENU IN MAGENTO 2 ADMIN

    magento-2-admin- menu My previous tutorial show you how to create a simple module in Magento 2, learn more here: http://www.venustheme.com/how-to-create-magento-2-module/....