Cheers!
I have this piece of code in a cron that goes through all orders returned from a query and cancel them. How can I re-stock the items belonging to the canceled order ?
$ordernumber = intval($order['increment_id']);
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('\Magento\Sales\Model\OrderRepository')->get($ordernumber);
$order->setState('canceled')->setStatus('canceled');
$order->save();
Thanks