I am trying to import Magento 1 order data to Magento 2, But I am facing issue for guest customers because there is no customer id. Please follow my code which i am using:
$om = \Magento\Framework\App\ObjectManager::getInstance();$resource = $om->get('Magento\Framework\App\ResourceConnection');$connection = $resource->getConnection();$tableName = $resource->getTableName('sales_order');$_orderData = array( 'entity_id' => $_dataValue[0], 'state' => $_dataValue[1], 'status' => $_dataValue[2], 'coupon_code' => $_dataValue[3], 'protect_code' => $_dataValue[4], 'shipping_description' => $_dataValue[5], 'is_virtual' => $_dataValue[6], 'store_id' => isset($_dataValue[7]) ? $_storeIdArray[$_dataValue[7]] : '', 'customer_id' => $_dataValue[7] );$_tableFileds = implode(',', array_keys($_orderData));$_tableValue = "'".implode("', '", $_orderData)."'";$_insertQuery = "INSERT INTO $tableName($_tableFileds) VALUES($_tableValue)";$connection->query($_insertQuery);
Hi @tim_pandal,
You can follow the below url to create a custom order.
https://www.siphor.com/programmatically-create-an-order-in-magento-2/
https://www.rakeshjesadiya.com/how-to-create-order-programmatically-in-magento-2/
I hope it will help you!
Thank you for your replay but these links are order creation but I am looking for existing order data import.