4
<?php

namespace Maxime\Helloworld\Observer;


use Magento\Framework\Event\ObserverInterface;

class Productsaveafter implements ObserverInterface
{

 public function execute(\Magento\Framework\Event\Observer $observer)

 {
  $post = $this->getRequest()->getPostValue();
    }

}

Used this code. But it didin't gives the post values.

8

In your observer constructor do:

public function __construct(
    \Magento\Framework\App\RequestInterface $request
)
{
    $this->_request = $request;
}

Then in your code use $this->_request to fetch post params, like below :

$post = $this->_request->getPost();
0
1
$data = $this->getRequest()->getParams();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.