Magento 2.3 Hook an event in 'Submit Shipment' process in Sales Order View(Adminhtml) — New Shipment Form

magento.stackexchange https://magento.stackexchange.com/questions/259088

Pregunta

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

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange
scroll top