How can I check if an order with a given increment id already exists in magento?

Posted by Thomas Vander Stichele on Stack Overflow See other posts from Stack Overflow or by Thomas Vander Stichele
Published on 2012-12-16T23:02:09Z Indexed on 2012/12/16 23:02 UTC
Read the original article Hit count: 250

Filed under:

I am new to Magento.

What's the proper way to check if an order with a given increment id already exists ?

The obvious way:

    $order = Mage::getModel('sales/order')->loadByIncrementId($reservedOrderId);
    if ($order) {
        Mage::log('already have order with id ' . $reservedOrderId);
        return $order;
    }

does not work, because I get a new and empty model instance back.

What's the correct way in magento to see if I have no such model for that id ?

© Stack Overflow or respective owner

Related posts about magento