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;
        }

        }
  }
}
2
  • did you get anything into these code? Commented Nov 15, 2018 at 4:01
  • Not getting any data, gives null Commented Nov 15, 2018 at 4:39

1 Answer 1

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
   } 
}
3
  • Not working for me Commented Nov 14, 2018 at 14:35
  • share the code which you are trying. Show how you post that data and how you try to access that data. Commented Nov 14, 2018 at 14:36
  • i have add my code Commented Nov 14, 2018 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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