I have a problem when trying to modify an order through a cronjob this code works perfectly, but when executing it inside the cronjob it indicates that error "Request does not match any route"
<?php
namespace Vendor\Module\Cron;
use Magento\Sales\Model\Order;
class cronTest
{
public function __construct(
) {
}
public function execute()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$orderId = 8;
$order = $objectManager->get('\Magento\Sales\Model\Order')->load($orderId);
$orderState = Order::STATE_PROCESSING;
$order->setState($orderState)->setStatus(Order::STATE_PROCESSING);
$order->save();
}
}
if I use this same code in an observer for example, it works without any problem
My crontab.xml is
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="default">
<job instance="Vendor\Module\Cron\cronTest" method="execute" name="testCronJob">
<schedule>* * * * *</schedule>
</job>
</group>
</config>
I have found a temporary solution, create an api and consume it from the cronjob to get the desired behavior