1

I have working on data migration from non-magento e-com website to magento 2.x EE. I have question about that I can't save the data after call save();

$customerOrder = $this->_objectManager->create('\Magento\Sales\Model\Order');
$customerOrder->setData('base_grand_total',$val->_amount); 

//total = shipping fee + items total
$customerOrder->setData('base_subtotal',$val->_orginal_price); //item totals
$customerOrder->setData('base_shipping_amount',$val->_shipping_fee);
$customerOrder->setData('base_to_global_rate',1);
$customerOrder->setData('base_to_order_rate',1);
$customerOrder->setData('store_id',1);//store ID
$customerOrder->setData('grand_total',$val->_amount);
$customerOrder->setData('subtotal',$val->_orginal_price);
$customerOrder->setData('total_qty_ordered',1);

$Orderpayment->save();

Fatal error: Call to a member function getMethodInstance() on null in D:\xampp\htdocs\hktshop_uat\vendor\magento\module-payment\Observer\SalesOrderBeforeSaveObserver.php on line 24

Anyone have experience on migration?

0

We need to set payment method for our order, for example:

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
    //$orderPayment = $objectManager->create('Magento\Sales\Api\Data\OrderPaymentInterface');
    $orderPayment = $objectManager->create('Magento\Sales\Model\Order\Payment');

    $orderPayment->setStoreId($this->_store_id)
        ->setMethod('checkmo')
        ->setPoNumber(' - ');
    $order->setPayment($orderPayment);
1
  • Thanks you very much, I can save the data into sales_order & sales_order_payment table by your suggestion. But I can't open the order detail on admin page. which tables or data I miss to insert ? The error : > Order View Information Changes have been made to this section that have not been saved. This tab contains invalid data. Please resolve this before saving. – Kllee Aug 16 '16 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.