0

i would like to set order to complete programmatically after they have been processed in another software. This is the typical code i found all over the internet:

$orderId = 1000120319; $order = $objectManager->create('\Magento\Sales\Model\Order') ->load($orderId); $orderState = \Magento\Sales\Model\Order::STATE_COMPLETE; $order->setState($orderState)->setStatus($orderState); $order->save(); 

All i get is this result:

Uncaught Magento\Framework\Exception\LocalizedException: Please provide payment for the order.

What i have to do, to set the payment completed as well? Thanks for your help in advanced

Best regards

2 Answers 2

1

Use loadByIncrementId instead of load.

0

I'm pretty sure you'll need to create an invoice for it first, though I don't have code handy for that. Here is an example solution for that: https://webkul.com/blog/how-to-programmatically-create-invoice-in-magento2/

1
  • thanks for your advice. that was my first idea. But $order->canInvoice() is false and if we try to create an invoice anyway we will end with "Uncaught Error: Call to a member function canCapture() on null" Commented Nov 19, 2020 at 19:15

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.