-
-
Save deniscsz/dfbdcd1715268549d6ae30eb563fa15a to your computer and use it in GitHub Desktop.
One-off tool to uncancel an order in magento 1.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(php_sapi_name()!=="cli"){ | |
echo "Must be run from the commend line."; | |
}; | |
/** | |
* Setup a magento instance so we can run this export from the command line. | |
*/ | |
require_once('app/Mage.php'); | |
umask(0); | |
if (!Mage::isInstalled()) { | |
echo "Application is not installed yet, please complete install wizard first."; | |
exit; | |
} | |
// Only for urls // Don't remove this | |
$_SERVER['SCRIPT_NAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_NAME']); | |
$_SERVER['SCRIPT_FILENAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_FILENAME']); | |
Mage::app('admin')->setUseSessionInUrl(false); | |
Mage::setIsDeveloperMode(true); ini_set('display_errors', 1); error_reporting(E_ALL); | |
try { | |
Mage::getConfig()->init(); | |
Mage::app(); | |
} catch (Exception $e) { | |
Mage::printException($e); | |
} | |
ini_set('memory_limit','500M'); | |
try{ | |
//@see http://magento.stackexchange.com/questions/7254/is-there-any-way-to-get-back-the-cancelled-order#comment189623_7255 | |
$incrementId = '100000835'; //replace this with the increment id of your actual order | |
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); | |
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING); | |
$order->setStatus('pending'); | |
$order->setBaseDiscountCanceled(0); | |
$order->setBaseShippingCanceled(0); | |
$order->setBaseSubtotalCanceled(0); | |
$order->setBaseTaxCanceled(0); | |
$order->setBaseTotalCanceled(0); | |
$order->setDiscountCanceled(0); | |
$order->setShippingCanceled(0); | |
$order->setSubtotalCanceled(0); | |
$order->setTaxCanceled(0); | |
$order->setTotalCanceled(0); | |
foreach($order->getAllItems() as $item){ | |
$item->setQtyCanceled(0); | |
$item->setTaxCanceled(0); | |
$item->setHiddenTaxCanceled(0); | |
$item->save(); | |
} | |
$order->save(); | |
echo "Order $incrementId has been un-canceled\n"; | |
} catch (Exception $e) { | |
//$response['error'] = $e->getMessage(); | |
Mage::printException($e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment