Permalink
Browse files

Update old order status with the runonce script

  • Loading branch information...
1 parent 4036dce commit 0f6cfd105d1f56b687b9eb5a0d909ebb82382c77 @aschempp aschempp committed Mar 29, 2012
Showing with 52 additions and 0 deletions.
  1. +52 −0 system/modules/isotope/config/runonce.php
@@ -58,6 +58,7 @@ public function run()
$this->renameFields();
$this->updateStoreConfigurations();
$this->updateOrders();
+ $this->initializeOrderStatus();
$this->updateImageSizes();
$this->updateAttributes();
$this->updateFrontendModules();
@@ -477,6 +478,57 @@ private function updateOrders()
// Fix for Ticket #383
$this->Database->query("UPDATE tl_iso_order_downloads SET downloads_remaining='' WHERE downloads_remaining='-1'");
}
+
+
+ private function initializeOrderStatus()
+ {
+ if (!$this->Database->tableExists('tl_iso_orderstatus'))
+ {
+ $this->Database->query("
+CREATE TABLE `tl_iso_orderstatus` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `pid` int(10) unsigned NOT NULL default '0',
+ `tstamp` int(10) unsigned NOT NULL default '0',
+ `sorting` int(10) unsigned NOT NULL default '0',
+ `name` varchar(255) NOT NULL default '',
+ PRIMARY KEY (`id`),
+ KEY `pid` (`pid`),
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
+
+ $blnUpdate = true;
+ }
+ else
+ {
+ $objRecords = $this->Database->query("SELECT COUNT(*) AS total FROM tl_iso_orderstatus");
+ $blnUpdate = $objRecords->total > 0 ? false : true;
+ }
+
+ if ($blnUpdate)
+ {
+ $GLOBALS['TL_LANG']['ORDER']['pending'] = 'Pending';
+ $GLOBALS['TL_LANG']['ORDER']['processing'] = 'Processing';
+ $GLOBALS['TL_LANG']['ORDER']['complete'] = 'Complete';
+ $GLOBALS['TL_LANG']['ORDER']['on_hold'] = 'On Hold';
+ $GLOBALS['TL_LANG']['ORDER']['cancelled'] = 'Cancelled';
+
+ $time = time();
+ $arrStatus = array_unique(array_merge
+ (
+ array('pending', 'processing', 'complete', 'on_hold', 'cancelled'),
+ $this->Database->execute("SELECT DISTINCT status FROM tl_iso_orders WHERE status!=''")->fetchEach('status'),
+ $this->Database->execute("SELECT DISTINCT new_order_status FROM tl_iso_payment_modules WHERE new_order_status!=''")->fetchEach('new_order_status')
+ ));
+
+ foreach( $arrStatus as $i => $status )
+ {
+ $strLabel = $GLOBALS['TL_LANG']['ORDER'][$status] == '' ? $status : $GLOBALS['TL_LANG']['ORDER'][$status];
+ $intId = $this->Database->prepare("INSERT INTO tl_iso_orderstatus (tstamp,sorting,name) VALUES ($time,$i,?)")->executeUncached($strLabel)->insertId;
+
+ $this->Database->prepare("UPDATE tl_iso_orders SET status=? WHERE status=?")->executeUncached($intId, $status);
+ $this->Database->prepare("UPDATE tl_iso_payment_modules SET new_order_status=? WHERE new_order_status=?")->executeUncached($intId, $status);
+ }
+ }
+ }
private function updateAttributes()

0 comments on commit 0f6cfd1

Please sign in to comment.