1

Does anyone know how to call observer for admin order success?

3

You can create events.xml file here and you can use checkout_submit_all_after event there.

app/code/Vendor/Module/etc/adminhtml/events.xml

Content for this file is..

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="checkout_submit_all_after">
        <observer name="admin_order_place_after" instance="Vendor\Module\Observer\AdminOrderPlaceAfter" />
    </event>
</config>

Now you need to create one Observer file here

app/code/Vendor/Module/Observer/AdminOrderPlaceAfter.php

<?php
namespace Vendor\Module\Observer;

use Magento\Framework\Event\Observer;

class AdminOrderPlaceAfter implements \Magento\Framework\Event\ObserverInterface
{
    public function execute(Observer $observer){
        $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/observer.log');
        $logger = new \Zend\Log\Logger();
        $logger->addWriter($writer);
        $logger->info('Backend order placed.');
    }
}

Hope this will help you!

1

<?xml version="1.0"?> <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="vendor_module_sales_order_place_after" instance="Vendor\Module\Observer\OrderPlaceafterSaveData"/> </event> </config>
Put this code in events.xml then create Observer directory and in there
use Magento\Framework\Event\ObserverInterface;
class OrderPlaceafterSaveData implements ObserverInterface

and make your magic happen

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.