Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6912563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:06:29+00:00 2026-05-27T09:06:29+00:00

Is there a way to programmatically reopen an order in Magento that has already

  • 0

Is there a way to programmatically reopen an order in Magento that has already reached complete or closed status? I have the following code which works for changing the status of an order, but I can’t get it to work for complete or closed orders.

// connect to magento
require_once('app/Mage.php');
umask(022);
Mage::app();

// check admin credentials
Mage::getSingleton('core/session', array('name' => 'adminhtml'));
$admin = Mage::getSingleton('admin/session');

if ( $admin->isLoggedIn() ) {
    // update order status
    $orderIncrementId = "100000001";
    $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
    $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
}

I got the current code here. On that page it says that it was tested with Magento 1.3.2.4, but I’m using Magento 1.6.x. Maybe that’s the issue?

Let me know if I need to provide more detail, and thanks for any help you can offer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:06:29+00:00Added an answer on May 27, 2026 at 9:06 am

    I don’t think that you’re having a Magento version issue here.

    Under specific circumstances Magento simply just does not allow to switch the state of an order back to Mage_Sales_Model_Order::STATE_PROCESSING.

    For example, usually you cannot save a Mage_Sales_Model_Order::STATE_PROCESSING state to any order, which already has had refunds (creditmemos). Neither in 1.3.2.4, nor in 1.6.x.

    This is by-design.

    Look at Mage_Sales_Model_Order::_checkState() to see under which circumstances Magento forces resetting the order state to STATE_COMPLETE or STATE_CLOSED, respectively.

    protected function _checkState()
    {
        if (!$this->getId()) {
            return $this;
        }
    
        $userNotification = $this->hasCustomerNoteNotify() ? $this->getCustomerNoteNotify() : null;
    
        if (!$this->isCanceled()
            && !$this->canUnhold()
            && !$this->canInvoice()
            && !$this->canShip()) {
            if (0 == $this->getBaseGrandTotal() || $this->canCreditmemo()) {
                if ($this->getState() !== self::STATE_COMPLETE) {
                    $this->_setState(self::STATE_COMPLETE, true, '', $userNotification);
                }
            }
            /**
             * Order can be closed just in case when we have refunded amount.
             * In case of "0" grand total order checking ForcedCanCreditmemo flag
             */
            elseif (floatval($this->getTotalRefunded()) || (!$this->getTotalRefunded()
                && $this->hasForcedCanCreditmemo())
            ) {
                if ($this->getState() !== self::STATE_CLOSED) {
                    $this->_setState(self::STATE_CLOSED, true, '', $userNotification);
                }
            }
        }
    
        if ($this->getState() == self::STATE_NEW && $this->getIsInProcess()) {
            $this->setState(self::STATE_PROCESSING, true, '', $userNotification);
        }
        return $this;
    }
    

    To answer your question: you could achieve what you’re trying to do by overriding the _checkState() method with your own method, which allows to set STATE_PROCESSING.

    Be aware though, that this most probably will cause the creation of new state contexts which Magento neither knows nor expects or can handle.

    If your changes wreak havoc, don’t blame me. You’ve been warned^^

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a public dropbox folder. Is there any way to programmatically scan that
In an android Activity is there a way to programmatically list the it has
Is there any way to programmatically find the frame that a function was defined
Is there any way (programmatically) that i can find the location of Resource folder.
Is there a way to programmatically deselect/wipe whatever the user has selected with the
some of my MyOpenId persona's have avatars. Is there any way to programmatically request
Is there a way to programmatically highlight an imageview in android? I am showing
Is there a way to programmatically force a Python script to drop into a
Is there a way to programmatically detect whether the microphone is on on Windows?
is there a way to programmatically access the age restriction set in the parental

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.