0

i want to get form data from checkout page in 2nd step, so i have use event observer.

I have use this controller_action_predispatch_checkout event.

I want to get post data so i have try this link Get post data, in Checkout success observer but not able to get post data.

Can any one help me how can i get post data?

event.xml

<event name="controller_action_predispatch_checkout">
       <observer name="ptg_paymentevent_observer_checkoutpredispatchobserver" instance="Ptg\Paymentevent\Observer\Checkoutpredispatchobserver" />
   </event>

Checkoutpredispatchobserver.php

<?php
namespace Ptg\Paymentevent\Observer;

use Magento\Framework\Event\ObserverInterface; 
use Magento\Framework\Event\Observer as EventObserver; 

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

  public function execute(\Magento\Framework\Event\Observer $observer)
  {
     //$order= $observer->getData('order');
     //$order->doSomething(); product = $observer->getEvent()->getProduct();
      $reqeustParams = $this->_request->getParams(); 
            echo '<pre>';
            var_dump($reqeustParams);
            echo '</pre>';




     return $this;
        }

        }
  }
}
  • did you get anything into these code? – Dhiren Vasoya Nov 15 '18 at 4:01
  • Not getting any data, gives null – Jimit Bhavsar Nov 15 '18 at 4:39
1

You need to try this code.

<?php namespace Vendor\Extension\Observer; 

use Magento\Framework\Event\ObserverInterface; 
use Magento\Framework\Event\Observer as EventObserver; 

class Yourclass implements ObserverInterface 
{ 
   protected $_request; 

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

   public function execute(EventObserver $observer) 
   { 
        $reqeustParams = $this->_request->getParams(); 
        //check into $requestparams
   } 
}
  • Not working for me – Jimit Bhavsar Nov 14 '18 at 14:35
  • share the code which you are trying. Show how you post that data and how you try to access that data. – Dhiren Vasoya Nov 14 '18 at 14:36
  • i have add my code – Jimit Bhavsar Nov 14 '18 at 14:49

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.