You can get Post Data value in the After plugin using Magento 2.
You can get all the Params() data after the plugin which is sent by request. If you send the query string Or data within the URL, you can get those data using getParams() in the after plugin.
You need to create a plugin for any Execute Method you want to extract data from the request.
You can get all the params value using the below syntax in afterPlugin,
$subject->getRequest()->getParams();
You can get all the post values using the below way,
$subject->getRequest()->getPostValue();
Example for getting Address Id after Delete Customer Address in Magento Backend,
<?php use Magento\Customer\Controller\Adminhtml\Address\Delete as MagentoCustomerDelete; class PluginDemo { /** * Address Delete Plugin after execute * Get Address Id and Customer id afterexecute Call */ public function afterExecute(MagentoCustomerDelete $subject, $result) { //$subject->getRequest()->getParams(); $customerId = $subject->getRequest()->getParam('parent_id', false); $addressId = $subject->getRequest()->getParam('id', false); // YOUR_CODE_HERE } }
You can get many other useful functions using the $subject in the After Plugin method by checking the below way,
get_class_methods($subject->getRequest());