Pergunta

<?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.

Foi útil?

Solução

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();

Outras dicas

$data = $this->getRequest()->getParams();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top