Hi,
I am new to magento. I am trying to create a observer to the event
class AfterOrderPlaced implements ObserverInterface { public function execute(\Magento\Framework\Event\Observer $observer) { { error_log(print_r("alterado pra chamar endpoint com guzzle \n", TRUE), 3, '/var/www/html/var/log/cotriba_errors.log'); $order = $observer->getEvent()->getData(); $order_content = json_encode($observer -> getEvent()-> getData()); $client = new \GuzzleHttp\Client(); $response = $client->request('POST', 'http://192.168.0.23:8080/hello', array( 'headers' => [], 'json' => $order_content )); return $this; } } }How can I get all the order data?
Hi @kellygoede46b1 ,
Can you try replacing line of code with options
$order = $observer->getEvent()->getData();
To
$order = $observer->getEvent()->getData('order');
Else
$order = $observer->getOrder();
Thanks!
Problem Solved! Click kudos & Accept as Solution.
Hi @kellygoede46b1 ,
In this case, can you try changing the event and try below mention the event to get the order data.
https://meetanshi.com/blog/get-order-data-from-magento-2-sales_order_place_after-event/
Thanks!
--------------------------------
Problem Solved! Click Kudos and Accept as Solution!