I am using plugin for converting "quote_item" to "sales_order_item" from below give code it work.

public function aroundConvert(
        \Magento\Quote\Model\Quote\Item\ToOrderItem $subject,
        \Closure $proceed,
        \Magento\Quote\Model\Quote\Item\AbstractItem $item,
        $additional = []
    ) {
        /** @var $orderItem \Magento\Sales\Model\Order\Item */
        $orderItem = $proceed($item, $additional);
        $orderItem->setCurrentSellerId($item->getCurrentSellerId());
        return $orderItem;
    }

But now i am want to convert my custom attribute("current_seller_id") data into "sales_order" custom column.

有帮助吗?

解决方案

You can create an observer for the event sales_model_service_quote_submit_before. This happens directly before the converted order is placed. In your observer you can access the quote and the order object and can transfer your custom attribute value from the quote to the order.

Try something like this in your observer:

public function execute(\Magento\Framework\Event\Observer $observer)
{
    $quote = $observer->getData('order');
    $order = $observer->getData('order');

    //get the current_seller_id from quote 
    $order->setCurrentSellerId($quote->getCurrentSellerId());

    //alternative: get the current_seller_id from the first quote_item where it is set 
    $quoteItems = $quote->getItems();
    foreach ($quoteItems as $quoteItem){
        if ($quoteItem->getCurrentSellerId() != ""){
            $order->setCurrentSellerId($quoteItem->getCurrentSellerId());
            break;
        }
    }
    return $this;
}
许可以下: CC-BY-SA归因
scroll top