1

I need to get a collection of all orders where the status is changed to completed today.

Currently i'm doing this:

$fromTime = date('Y-m-d', strtotime('yesterday midnight'));

$yesterdaysOrders = Mage::getModel('sales/order')->getCollection()
    ->addAttributeToFilter('created_at', array('from' => $fromTime))
    ->addAttributeToFilter('status', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE));

But with this I only get orders CREATED today - not the once completed today.

1
  • If you need a more exact solution than the accepted one, there is also the sales_flat_order_status_history table which holds the exact date an order was completed on.
    – Louis B.
    Nov 26, 2019 at 11:22

1 Answer 1

2

You can do it by replacing created_at with updated_at.

Please note that if you update the order after it has been completed, then this data will change. Magento does not store the completed_at date out of the box.

0

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.