I want to get POST data in Model file, Which is my custom file of AccountManagement
/app/code/[Vendor]/[Module]/Model/AccountManagement.php
Note:
I can access it through $_POST, 'superglobal' variable
but i don't wanna use it that way, Because it's not valid for Magento standard
.
Because Magento use to featch POST
and REQUEST
data using this method in Controller.
$this->postData = $this->getRequest()->getPostValue();
But i am not able to use same method in Model
file.
So anyone have any idea to fetch POST data in Model file IN Magento 2x, As per Magento Standard
Best Answer
Please try below code. We will inject Http class in the constructor and use that to get post data. This is a standard way of Magento 2