Create etc/events.xml
.
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_place_after">
<observer name="sales_order_place_after" instance="Vendor\Module\Observer\ChangeOrderStatus" />
</event>
</config>
Create Vendor/Module/Observer/ChangeOrderStatus.php
.
<?php
namespace Vendor\Module\Observer;
use Magento\Framework\Event\Observer as EventObserver;
use Magento\Framework\Event\ObserverInterface;
class ChangeOrderStatus implements ObserverInterface
{
public function execute(EventObserver $observer)
{
$order = $observer->getEvent()->getOrder();
$order->setStatus('processing');
return $this;
}
}
Clear cache: php bin/magento cache:clean
. And then check it.