<?php
namespace FiloBlu\Storelocator\Observer;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

/**
 *
 */
class AddRmaOrderData implements ObserverInterface
{

    /**
     * @param Observer $observer
     */
    public function execute(Observer $observer)
    {
        $parentOrder = $observer->getEvent()->getParentOrder();
        $order = $observer->getEvent()->getNewOrder();
        if ($order && $order->getId() && $parentOrder->getPickupInStoreId() && $parentOrder->getPickupInStoreEmail()) {
            $order->setPickupInStoreId($parentOrder->getPickupInStoreId());
            $order->setPickupInStoreCode($parentOrder->getPickupInStoreCode());
            $order->setPickupInStoreEmail($parentOrder->getPickupInStoreEmail());
            $order->setPickupInStoreHash(md5(time()));
        }
    }
}
