1

How to Order status change Processing to complete in magento 2.3

2

You can Change status this way..

    $orderId = 1; // here order id

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $order = $objectManager->create('\Magento\Sales\Model\Order')
                               ->load($orderId); 

    $order->setState("complete")->setStatus("complete");

    $order->save();
3

You can Change the order status to complete using repository Class of order entity \Magento\Sales\Api\OrderRepositoryInterface

    $order = $this->orderRepository->get($orderiId);
    $order->setStatus($completeStatus)->setState($completeStatus);
    $this->orderRepository->save($order); 

Code Looks Like:

<?php
namespace {ClassNameSpace};

use Magento\Framework\Exception\NoSuchEntityException;

class Test {

    /**
     * @var \Magento\Sales\Api\OrderRepositoryInterface
     */
    private $orderRepository;

    public function __construct(
    \Magento\Sales\Api\OrderRepositoryInterface $orderRepository      
    ) {

        $this->orderRepository = $orderRepository;
    }
    public function ChangeOrderStatusToComplete()
    {
        $completeStatus = \Magento\Sales\Model\Order::STATE_COMPLETE;
        $id = 2;
        try{
            $order = $this->orderRepository->get($id);
            $order->setStatus($completeStatus)->setState($completeStatus);
            $this->orderRepository->save($order);           
        } catch (NoSuchEntityException $ex) {
            // error Happen
        }


    }
}
2

This is duplicated from this Link

use Magento\Sales\Model\Order;

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.