0

The event sales_order_shipment_save_after is not working in magento 2.3.4 after shipment submit.

event.xml file

SubmitShipmentAfter.php file

addWriter($writer); $logger->info($result); } }
8
  • <?xml version="1.0"?> <config xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="sales_order_shipment_save_after"> <observer name="sales_order_shipment_after_save" instance="Flashdemo\Ship\Observer\SubmitShipmentAfter" /> </event> </config> Feb 4, 2022 at 5:19
  • <?php namespace Flashdemo\Ship\Observer; use Magento\Framework\Event\ObserverInterface; class SubmitShipmentAfter implements ObserverInterface { public function execute(\Magento\Framework\Event\Observer $observer) { $result = "hello"; $result = json_encode($result, true); $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log'); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $logger->info($result); } } Feb 4, 2022 at 5:20
  • where you put events.xml in area or global? Feb 4, 2022 at 5:41
  • app\code\Flashdemo\Ship\etc\adminhtml Feb 4, 2022 at 5:43
  • ok try to move it in "app\code\Flashdemo\Ship\etc" and check once Feb 4, 2022 at 5:45

1 Answer 1

0

First of all change your event.xml to events.xml as you are missing s in events.xml

<?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_shipment_save_after">
        <observer name="save_sales_order_shipment_after" instance="Vendor\Module\Observer\SubmitShipmentAfter" />
    </event>
</config>

Then inside Vendor\Module\Observer\SubmitShipmentAfter.php

<?php

namespace Vendor\Module\Observer;

use Magento\Framework\Event\Observer;

class SubmitShipmentAfter implements \Magento\Framework\Event\ObserverInterface
{
    public function execute(Observer $observer)
    {
        //write your code here
    }
}
1
  • still no luck..Actually my file name was already events.xml.. Feb 4, 2022 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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