I need to call some API on ship item from magento but nothing is working.

Following things I already tried:

1) Use event/observer: sales_order_shipment_save_after (As I thought It will work in magento 2 because it is work fine in magento 1.x).

2) Override controller: \Magento\Shipping\Controller\Adminhtml\Order\Shipment\Save but controller overriding is also not working.

Please help.


1 Answer 1


--Sales Order Shipment Save After event:


<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <event name="sales_order_shipment_save_after">
        <observer name="sales_order_shipment_after"
                  instance="Company\Module\Observer\SalesOrderShipmentAfter" />



namespace Company\Module\Observer;

use Magento\Framework\Event\ObserverInterface;

class SalesOrderShipmentAfter implements ObserverInterface
    public function execute(\Magento\Framework\Event\Observer $observer)
        $shipment = $observer->getEvent()->getShipment();
        /** @var \Magento\Sales\Model\Order $order */
        $order = $shipment->getOrder();
        // Do some things


--Override controller

We can use Plugin or preference.


<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    <preference for="Magento\Shipping\Controller\Adminhtml\Order\Shipment\Save"
                type="Company\Module\Controller\Adminhtml\Order\Shipment\Save" />



namespace Company\Module\Controller\Adminhtml\Order\Shipment;

class Save extends \Magento\Shipping\Controller\Adminhtml\Order\Shipment\Save


Make sure that you clean Magento Cache and remove var/generation

  • hi I am getting unknown function getOrder() i am using event and obsertver Nov 8, 2017 at 7:53
  • hello @Khoa, I am using this event and trying to get source_code from "inventory_shipment_source" table, but in this event data not present in the table for current shipment_id Nov 4, 2020 at 11:42

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.