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?

$orders = $objectManager->create('Magento\Sales\Model\Order')->getCollection();
$orders->addFieldToSelect('*')->addFieldToFilter('status', array('in' => array(cancelled)));

Please try this.


You can use this


$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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.