cancel
Showing results for 
Search instead for 
Did you mean: 

magento 2 how to import guest user order using php

magento 2 how to import guest user order using php

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);
2 REPLIES 2

Re: magento 2 how to import guest user order using php

Re: magento 2 how to import guest user order using php

Thank you for your replay but these links are order creation but I am looking for existing order data import.