News:

Support the VirtueMart project and become a member

Main Menu

Order migration - Date

Started by manburg6, July 19, 2012, 13:56:45 PM

Previous topic - Next topic

manburg6

Hello,

I'm migrating my Joomla 1.5 and VM 1.1.9 to new version.

I've found an error during order migration:

all the old order, migrated to VM 2.0.8, are with "Order Date" and "Last Modified Date" set to migration time.
Shold be copied with the original order date.

Any suggestion?

Thanks,
Mario

klattr1

I've also had the same issue. Is there a fix?

xpozay

Having the same problem with VM 2.0.16d except that the order date is correct.  However, the last modified date / all the history of events dates are set to the migration date.

History of events is when the order changes from pending to confirmed to shipped, etc.  All these dates are modified.

Is there a configuration setting that resolves this?  Or was this fixed?

I also found this thread but checked migrator and it is already written like suggested.

I previously found this http://forum.virtuemart.net/index.php?topic=106574.msg355695#msg355695 but can see this is already in migrator.php

Milbo

We use this,


$orderData->created_on = $this->_changeToStamp($order['cdate']);
$orderData->modified_on = $this->_changeToStamp($order['mdate']); //we could remove this to set modified_on today


strange. Maybe you are not superadmin doing the migration.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

xpozay

#4
Yes my code is the same.  Also I have Super Admin access while doing the migration.

I did a little more digging and to be honest I am not sure how all the others have been successfully migrating.  Perhaps they are not really checking as this problem is not just with orders - it is for all of the tables: products, categories, orders.  I did not check media or anything else.

Orders

If you look at orders in migrator.php around line 1383
$orderData->created_on = $this->_changeToStamp($order['cdate']);
$orderData->modified_on = $this->_changeToStamp($order['mdate']); //we could remove this to set modified_on today


It appears to be OK however if you look at the table directly:
- in table created_on is ok
- in table modified_on is written as the time the migrator is run (should not be the case)

Next if you look at  order_item around line 1412
$item['created_on'] = $this->_changeToStamp($item['cdate']);
$item['modified_on'] = $this->_changeToStamp($item['mdate']); //we could remove this to set modified_on today

Similarly it looks OK but if you look at the table
- created_on is ok
- modified_on is migrator date (should not be the case)

Next if you look at orders history around line 1428
$q = 'SELECT * FROM `#__vm_order_history` WHERE `order_id` = "'.$order['order_id'].'" ';
$this->_db->setQuery($q);
$oldItems = $this->_db->loadAssocList();

foreach($oldItems as $item){
$item['virtuemart_order_id'] = $newId;
//$item['order_status_code'] = $orderCodeToId[$item['order_status_code']];


$orderHistoriesTable = $this->getTable('order_histories');
$orderHistoriesTable->bindChecknStore($item);
$errors = $orderHistoriesTable->getErrors();
if(!empty($errors)){
foreach($errors as $error){
$this->_app->enqueueMessage('Migration orderhistories: ' . $error);
}
$continue = false;
break;
}
}


There is no change of date format at all neither created_on or modified_on fields are converted to the new format and the dates are set to the date / time the migrate is run (should not be the case)


So why is it that for all the "mdates", they are written with the "today's" date / time ie date/time stamp the migrator is run?

After some searching I found the line 285 in vmtables
$this->modified_on = $today;

This line was setting all of the "mdates" to the date /time the migrator is being run.

For created_on dates ("cdate"), there is a check immediate about the $today statement
if($this->created_on=="0000-00-00 00:00:00"){
$this->created_on = $this->$today;

which does a check before writing.  It is correct to assume that this check should also be implemented on 'mdate' / modified_on fields?


I commented out that line ($this->modified_on = $today;) and the mdate started to show up in the tables but with some problems:
1) The date was not converted to the new format so all the dates were screwed up but not at least the migrator date.  I assume using the check like what is done on creatd_on will resolve this?

2) modified_date for order history is all set to 0000-00-00 00:00:00 because this field does not exist in the old vm tables.  This is logical as these records are never modified because they are status updates.  That said, it could also be logical to write the creation date there instead so that the created_on and the modified_on were the same.

Please advise me what and where should be changed to make this work properly.

Thanks

Also, for the setting of created_on date  = today in vmtables.php as shown above, I am not convinced this is correct either.  We are doing a migration and therefore there should be no changes to old data.  In fact, in many countries it would be illegal to modify historical records for audit and taxation purposes. 

xpozay