How to get order id in invoice using plugin ?
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">
<type name="Magento\Sales\Controller\Adminhtml\Order\Invoice\Save">
<plugin name="admin_plugin_order_invoice_save_after" type="Companyname\Modulename\Controller\Adminhtml\Order\Invoice\Save"/>
</type>
</config>
Save.php
<?php
namespace Companyname\Modulename\Controller\Adminhtml\Order\Invoice;
ini_set('display_errors',1);
error_reporting(E_ALL);
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory;
class Save
{
public function afterExecute(\Magento\Sales\Controller\Adminhtml\Order\Invoice\Save $subject,$result)
{
echo "order id ---".$result->getEntityId();
echo "<pre>";
print_r($result->getData());
die;
}
}
Unable to get anything. Using this code unable to get order it or invoice id. Anyone know how to get order id,update order or get invoice id ?