I want to show list of the guest user in my custom module. Which is the best way to get the list of the guest order.
How can i get list of the guest orders?
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $lastyear = date('Y-m-d', strtotime("-1 year")); $order = $objectManager->create('Magento\Sales\Model\Order')->getCollection()->addAttributeToFilter('customer_id', $customer_id)->addAttributeToFilter('state', 'complete')->addAttributeToFilter('created_at', ['gteq' => $lastyear]);
To get the guest orders i am getting collection of all the orders and checking customer email address. If user with that email address doesn't exist then consider it as guest order.
Is this correct flow? Is there any other flow to check guest orders?
Any help would be appreciated.