سؤال

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

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

$data = $this->getRequest()->getParams();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top