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?

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

Please try this.

| improve this answer | |
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!

| improve this answer | |

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.