0

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 2

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

Please try this.

1

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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