Quote Originally Posted by JeremyToaster View Post
Thanks for making the updates, when I ran this months ago on my test server, I had to manually remove all the apostrophes in my database...took a long time, but eventually everything worked just fine.

What I am trying to do now though is, add the "Past / CUrrent / Pending Orders" which I think is very critical to converting over to ZenCart.

I am trying to figure this part out on my own, and this is what I have come up with so far.
The only problem I see is that, OsCommerce has an "orders_session_info" table and ZenCart does not, and ZenCart has an "orders_products" table and OsCommerce does not. But all the others seem to match up.
If someone with some expertise can look this over and make any corrections and let me know if it could be patched into the script that would be made of awesome!

Thanks

jeremy

PHP Code:
$query_orders "SELECT * FROM orders";
$orders mysql_query($query_orders);
$i 0;
echo 
'exporting orders';
while (
$export_record mysql_fetch_assoc($orders)) {
    
$import_orders[$i]['orders'] =  $export_record['orders'];
//    $import_orders[$i]['orders_products'] =  $export_record['orders_products'];
    
$import_orders[$i]['orders_products_attributes'] =  $export_record['orders_products_attributes'];
    
$import_orders[$i]['orders_products_download'] =  $export_record['orders_products_download'];
//    $import_orders[$i]['orders_session_info'] =  $export_record['orders_session_info'];
    
$import_orders[$i]['orders_status'] =  $export_record['orders_status'];
    
$import_orders[$i]['orders_status_history'] =  $export_record['orders_status_history'];
    
$import_orders[$i]['orders_total'] =  $export_record['orders_total'];
    
$i++;
    echo 
'.';
}
mysql_free_result($orders);

echo 
'<br><br>';

echo 
'importing orders';
mysql_query("TRUNCATE `orders`");
while (list(
$i, ) = each($import_orders)) {
    
$insert_orders "INSERT INTO zen_orders SET
    zen_orders = '" 
$import_orders[$i]['orders'] . "', 
//    zen_orders_products = '" 
$import_orders[$i]['orders_products'] . "',
     zen_orders_products_attributes = '" 
$import_orders[$i][''orders_products_attributes'] . "'
     
zen_orders_products_download '" . $import_orders[$i]['orders_products_download'] . "'
//    zen_orders_sessions_info = '" . $import_orders[$i]['orders_session_info'] . "',
     
zen_orders_status '" . $import_orders[$i]['orders_status'] . "'
     
zen_orders_status_history '" . $import_orders[$i]['orders_status_history'] . "'
     
zen_orders_total '" . $import_orders[$i]['orders_total'] . "',  
    
";
    
$success = mysql_query($insert_orders);
    if (!
$success) { echo mysql_error(); exit;}
    echo '.';
}
    
echo '<br><br>'; 
Jeremy,

Couple of things:
1. the RC1 OSC did not have an orders_sessions_info table, so I didn't have it in mine. I doubt you will need this unless you are expecting customers to have products saved in their session during the conversion... coincidentally, all of your sessions will have to be new with Zen when you go live anyway. I would suspect you don't need this table at all.
2. I wouldn't know where to begin if your OSC installation does not have a orders_products table. All RC1 installations should have it. If there are no source records, that's a different story and the script will simply bypass that table 'cause there's nothing to migrate. I can't for the life of me imagine how it would happen, so I can't really comment on it. Yours must be a completely customized application if that's the case.
3. The script dumps everything in the Zen target tables it copies into, so beware, do backups before and after and check it only on a test system before doing a migration. Therefore, all closed, open, pending, and all of your order statuses will be migrated. This is important because if you have payment modules defaulted to order statuses, make sure they are properly updated after the migration to the OSC statuses. Basically, after testing, and setting up your Zen install in production, you can do a final customer and orders cutover, which is why I separated these out into separate migrations in the latest release.