I want to get all the orders where the status is pending. I want to do a second check where if the item status is cancelled. Is this possible to do?
2 Answers
$orders = $objectManager->create('Magento\Sales\Model\Order')->getCollection();
$orders->addFieldToSelect('*')->addFieldToFilter('status', array('in' => array(cancelled)));
Please try this.
You can use this
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$pendingOrdersCollection = $objectManager->get("\Magento\Sales\Model\Order")->getCollection()->addFieldToFilter('status', array('eq' => 'pending'));
$canceledOrdersCollection = $objectManager->get("\Magento\Sales\Model\Order")->getCollection()->addFieldToFilter('status', array('eq' => 'canceled'));
?>
Hope this will help you!