I would like to get the items that added via admin panel in the order page.
I have created the observer to listen to Create New Order
button event like this :
public function execute(Observer $observer)
{
$event = $observer->getEvent();
/** @var OrderInterface $order */
$order = $event->getOrder();
/** @var OrderItemInterface[] $orderItems */
$orderItems = $order->getItems();
/** @var Quote $quote */
$quote = $event->getQuote();
/** @var CartInterface[] $quoteItems */
$quoteItems = $quote->getItems();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$logger= $objectManager->create('\Psr\Log\LoggerInterface');
$logger->debug('Fabelio Observer::');
$logger->debug('Fabelio Observer:: item id = ' . $quoteItems[0]->getId());
$logger->debug('Fabelio Observer:: order item sku ' . $orderItems[0]->getSku());
$this->quoteSubmitBeforeProcess->processSales($quoteItems,$orderItems);
return $this;
}
When I try to create new order in the admin panel I got :
Fatal error: Uncaught Error: Call to a member function getId() on null
Now I know that the $quoteItems = $quote->getItems();
giving me a null value.
So How to get the quote items and order items from admin here ? I successfully getting the data from front-end side but not in the admin side .
sales_model_service_quote_submit_before
this event.$quote->getAllItems()
and check