I have created etc/events.xml
as:
<?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:Event/etc/events.xsd">
<event name="sales_order_place_after">
<observer name="process_gateway_redirect" instance="Magento\SamplePaymentGateway\Observer\ProcessGatewayRedirectOrderPlaceAfter" />
</event>
</config>
And observer for it:
<?php
namespace Magento\SamplePaymentGateway\Observer;
use Magento\Framework\Event\ObserverInterface;
class ProcessGatewayRedirectOrderPlaceAfter implements ObserverInterface
{
protected $orderFactory;
public function __construct(\Magento\Quote\Model\QuoteFactory $quoteFactory,
\Magento\Sales\Model\Order $orderFactory)
{
$this->orderFactory = $orderFactory;
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
echo 'here I\'m';
$orderIds = $observer->getEvent()->getOrderIds();
$lastorderId = $orderIds[0];
$order = $this->orderFactory->load($lastorderId);
var_dump($order);
die();
}
}
But the event is not executing, one page success is shown.
I even tried creating the etc/frontend/events.xml
with same code. Anyway the event is not triggered.
I have found that many people are using this event and discussing about other kind of issues.
Many friends are suggesting me to use checkout_submit_all_after
and checkout_onepage_controller_success_action
. I know about these events and have used previously. But my question is still the same.
Is it impossible to catch the sales_order_place_after
?
vendor\magento\module-sales-rule\Observer\SalesOrderAfterPlaceObserver.php
because in coresales_order_place_after
event used. If you can see log then there must be something in your module