I am using "controller_action_predispatch_sales_order_reorder" event to find out whether an order is reorder or not. Using this event I am able to get original orderId but along with that I want Order details as well which were ordered in the original order.
How can I get that from this event? I have already tried getOrder(), getProduct(), getQoute(), getAllItems() everything is coming up as null.
Here is my code
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<!-- Reorder from Admin side-->
<event name="sales_convert_order_to_quote">
<observer name="admin_reorder" instance="VoltLighting\OrderInfo\Observer\AdminReorder"/>
</event>
<!-- Reorder from customer side-->
<event name="controller_action_predispatch_sales_order_reorder">
<observer name="customer_reorder" instance="VoltLighting\OrderInfo\Observer\CustomerReorder"/>
</event>
<event name="checkout_onepage_controller_success_action">
<observer name="customer_reorder_success" instance="VoltLighting\OrderInfo\Observer\CustomerReorderSuccess"/>
</event>
<event name="checkout_cart_product_add_after">
<observer name="customer_predispatch_cart" instance="VoltLighting\OrderInfo\Observer\CustomerReorderCart"/>
</event>
</config>
Here is my Observer file
<?php
namespace VoltLighting\OrderInfo\Observer;
use Magento\Customer\Model\Session;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
class CustomerReorder implements ObserverInterface
{
protected $customerSession;
public function __construct(Session $customerSession)
{
$this->customerSession = $customerSession;
}
public function execute(Observer $observer)
{
$order = $observer->getEvent();
$entity_id = $order->getRequest()->getParam('order_id');
$customer = $this->customerSession;
$parentOrder = [$entity_id, []];
$customer->setMyValue($parentOrder);
}
}