--Sales Order Shipment Save After event:
app/code/Company/Module/etc/adminhtml/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="sales_order_shipment_after"
instance="Company\Module\Observer\SalesOrderShipmentAfter" />
</event>
</config>
app/code/Company/Module/Observer/SalesOrderShipmentAfter.php
<?php
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.
app/code/Company/Module/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Shipping\Controller\Adminhtml\Order\Shipment\Save"
type="Company\Module\Controller\Adminhtml\Order\Shipment\Save" />
</config>
app/code/Company/Module/Controller/Adminhtml/Order/Shipment/Save.php
<?php
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