Skip to content

Instantly share code, notes, and snippets.

@trabulium
Created January 22, 2014 01:42
Show Gist options
  • Save trabulium/8552088 to your computer and use it in GitHub Desktop.
Save trabulium/8552088 to your computer and use it in GitHub Desktop.
Close Magento Orders - it's a once off thing. Don't really care about repercussions.
// Instantiate Magento
define('MAGENTO_ROOT', "shop");
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::init();
//$orderIds = array('100006363');
//
// For Below to Work, change line 652 to false temporarily ie: return $this->_setState($state, $status, $comment, $isCustomerNotified, false);
// in app/code/core/Mage/Sales/Model/Order.php
foreach($orderIds as $orderIncrementId){
$order = Mage::getModel('sales/order')
->loadByIncrementId($orderIncrementId);
$userNotification = "Closed Manually due to no stock";
//$order->_setState(Mage_Sales_Model_Order::STATE_COMPLETE, false, '', $userNotification, null, false);
$order->setState(Mage_Sales_Model_Order::STATE_CLOSED, $userNotification, false);
$order->addStatusToHistory(Mage_Sales_Model_Order::STATE_CLOSED)->save();
echo "Closed Order" . $orderIncrementId . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment