Question

I want to hook some event on Submit Shipment button in Sales Order View New Shipment Form.
I want the event to hook when admin clicks on Submit Shipment button.

Has anyone tried to do it before? Which file should be overridden?
Any reference please.

Please check the image below:

enter image description here

Was it helpful?

Solution

I solved this after making some researching

Through Overriding New Shipment Save Controller using a Plugin

app/code/Vendor/CustomModule/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="Vendor\CustomModule\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
{
   //did my custom logic here 
}

reference: Magento 2 - sales_order_shipment_save_after

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top