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

Pergunta

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

Foi útil?

Solução

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 em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top