I am trying to print order details in Log /return JSON result when a new order is placed. Nothing is printing in System.log
or in exception.log
,
Please check my code below, Let me know where I am doing wrong.
\app\code\Autosynch\Sale\registration.php
<?php /**
* Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details.
*/
\Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Autosynch_Sale',
__DIR__
);
\app\code\Autosynch\Sale\etc\module.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Autosynch_Sale" setup_version="0.0.1">
</module>
</config>
\app\code\Autosynch\Sale\etc\event.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_submit_all_after">
<observer name="modulename_sales_order_place_after" instance="Autosynch\Sale\Observer\OrderPlaceAfter" />
</event>
</config>
\app\code\Autosynch\Sale\Observer\OrderPlaceAfter.php
<?php
namespace Autosynch\Sale\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
class OrderPlaceAfter implements ObserverInterface
{
protected $_logger;
/**
* @param \Psr\Log\LoggerInterface $_logger
*/
public function __construct(
\Psr\Log\LoggerInterface $_logger
){
$this->_logger = $_logger;
}
public function execute(Observer $observer)
{
$order = $observer->getEvent()->getOrder();
$this->_logger->info($order->getData());
$this->_logger->debug($order->getData());
//var_dump($order->getData());
//exit;
}
}