Forums / All Other Contributions/Addons / OsCommerce Data Importer - Errors

OsCommerce Data Importer - Errors

Results 1 to 20 of 252
27 Feb 2008, 00:57
#1
albertsavage avatar

albertsavage

New Zenner

Join Date:
Feb 2008
Posts:
27
Plugin Contributions:
0

OsCommerce Data Importer - Errors

Hi all,

I installed the OsCommerce Data Importer and started testing it out on a test db to see how it would work.. as I am migrating from OSc to Zen.

I found 2 problems that someone could perhaps help me with.

1. I have a table prefix. I hardcoded it in the sql statements (my zen tables starts with zen_) Any ideas on how to add a prefix? I'd be happy to submit it back as a contribution for download when I was done.

2. I am getting errors any time an apostrophe is used. (for example, I have a customer name that is O'Connor) which causes the process to fail. I could go through and modify each customer name, but since I haven't reached the part where I start loading product descriptions, I'm sure I haven't seen the last of this pesky problem. Isn't there a quick way to account for this within a script? Like... stripslashes/addslashes? Forgive me for talking out of my ######## here since I'm not an accomplished PHP programmer. If anyone could look at the code here and start me out, I'll update and test!

Any help would be appreciated!

Thanks,
Albert
19 Mar 2008, 23:52
#2
jimbofoxman avatar

jimbofoxman

New Zenner

Join Date:
Mar 2008
Posts:
28
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

I am trying to use the Netsparx OSC data importer, but I think the problem is that my original database has table prefixes. In the attachment is the code I am using, but obviously it doesn't have the table prefix being used. Anyone have any suggestions for including the table prefix? Or duplicating a database but with out the table prefixes?
01 Apr 2008, 06:20
#3
zerofriends avatar

zerofriends

New Zenner

Join Date:
Apr 2008
Posts:
2
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

I have been using oscommerce for the last year and wanted to upgrade to zencart. I just installed a fresh version of zencart 1.3.8a on my site. The only thing that I have changed is that I added the Cherry Zen 1.5 template. Now I am trying to import my oscommerce database (customers, products, etc) into zencart with the "osCommerce Data Importer" contribution submitted by netsparx.org that is found in the download section of the zencart site. I defined the database variables (database, username, and password) in the php file as instructed then I ran the php file on my server. it seemed to run smoothly during the exporting process but when it reached the importing section of the script it ran into a problem. This is the echo display that the script gave me when I ran it:

Connected Database Server
Database Opened


exporting customers.................................................................................................................................................................................................................................................................................................................................................................

exporting address book.........................................................................................................................................................................................................................................................................................................................................................................

exporting categories........

exporting category descriptions........

exporting products.........................................................................................................................

exporting product descriptions.........................................................................................................................

exporting directory structure..........................................................................................................................

exporting products_options.

exporting products_options_values...........

exporting products_options_values_to_products_options...........

exporting products_attributes............................................................................................................

exporting specials

exporting reviews..............

exporting review descriptions..............


importing customers.............................................................................................................................................................................................................................................................

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Atiqah', customers_lastname = 'Halim', customers_dob = '', customers_em' at line 4



I am not sure what I am doing wrong or what isn't working. If anyone could give me some advice I would greatly appreciate it. or if anyone has had luck with one of the other contributions. It will be a huge setback if I am not able to import my customers and their orders into Zen Cart so I do hope that someone can help me.

Thank you for your time,
Adam
08 Apr 2008, 01:38
#4
nhradeuce avatar

nhradeuce

New Zenner

Join Date:
Sep 2006
Posts:
64
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

Most likely there is a special character that's breaking SQL in that record. Take a look at your customer Halim Atiqah, I bet there is a ' in there somewhere.
05 May 2008, 21:54
#5
albertsavage avatar

albertsavage

New Zenner

Join Date:
Feb 2008
Posts:
27
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

I corrected this problem with my most recent issuance of the OSC Data importer. I had the same problems with customers having apostrophes in names and addresses. There was a simple mysql fix to handle those exceptions
05 May 2008, 21:55
#6
albertsavage avatar

albertsavage

New Zenner

Join Date:
Feb 2008
Posts:
27
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

I have added table prefixes to the new code just released. Good luck
05 May 2008, 21:56
#7
albertsavage avatar

albertsavage

New Zenner

Join Date:
Feb 2008
Posts:
27
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

OK, I was good enough to fix it myself and issue an update. I wanted to make sure that everything was in order and tested before I released it, so the newer version now takes care of these issues.
11 Jun 2008, 03:55
#8
jeremytoaster avatar

jeremytoaster

New Zenner

Join Date:
Jan 2008
Posts:
8
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

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]$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>';[/PHP]
11 Jun 2008, 18:59
#9
albertsavage avatar

albertsavage

New Zenner

Join Date:
Feb 2008
Posts:
27
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

JeremyToaster:

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]$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>';[/PHP]


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.
17 Jun 2008, 16:17
#10
jeremytoaster avatar

jeremytoaster

New Zenner

Join Date:
Jan 2008
Posts:
8
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

Hey Albert,
Yes definitely makes sense not needing the sessions_info table.

I may have just over looked the orders_products table, I'll check again and see if it is there. I'm sure it is, as my installation is very standard with only Visual customization.

So do you think the queries I wrote are correct other than the two issues mentioned?
This is my first time to write SQL queries.
If they are correct, would you want to integrate them into the script you published?

jeremy
17 Jun 2008, 19:02
#11
albertsavage avatar

albertsavage

New Zenner

Join Date:
Feb 2008
Posts:
27
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

Jeremy,

I'll admit... I can't make heads or tails of your code, and I'm not sure what you're trying to do, so I can't really see the vision. It appears as if you're declaring individual tables, but clearing a specific table (orders). Either way, there are no fields used.

Can you please try to explain what you were trying to do?

Maybe my instructions weren't clear enough on the original, the way the scripts are intended to be used is that at the beginning of working on your new site, you can make a copy of your current OSC database using all 3 import scripts (products, customers, orders), but people often want to change the products information during the time of the migration to reflect new content, meta tags, pricing, descriptions whatever, so I split out the customers and orders into separate files. When you go live with your new site, you can re-run the customers and orders script to get the most up to the second information after you bring your Zen site up.

I would appreciate you explaining what the current script is deficient in the migration so that it can be improved upon.

Since the scripts can be run in seconds (rather than minutes or hours), you can be up and running with your new Zen site nearly instantly after copying the site files up.

In the end, test, test, test. I went through probably 50 iterations before I felt that I could comfortably release the code that I did. I don't yet get the sense that this has been tested, can you confirm?

Best wishes,
Albert

JeremyToaster:

Hey Albert,
Yes definitely makes sense not needing the sessions_info table.

I may have just over looked the orders_products table, I'll check again and see if it is there. I'm sure it is, as my installation is very standard with only Visual customization.

So do you think the queries I wrote are correct other than the two issues mentioned?
This is my first time to write SQL queries.
If they are correct, would you want to integrate them into the script you published?

jeremy
17 Jun 2008, 19:26
#12
jeremytoaster avatar

jeremytoaster

New Zenner

Join Date:
Jan 2008
Posts:
8
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

Hey Albert,
I must just have an old version of your script or something, because the script I have exports only these details

Customers
Address Book
Categories
Category Descriptions
Products
Product Descriptions
Directory Structure
Products Options
Products Options Value
Products Options Values To Products Options
Products Attributes
Specials
Reviews
Review Descriptions


And that's it, there is no exportation of Orders anywhere. That's why I was copying your format for "Customers" and just replacing everything with "Orders" for corresponding tables in OsC and ZenCart.

If you have a new script that exports Orders, Past, Current, Pending, Shipped, etc, please point me to it as that would be great ! and my hacking would be unnecessary :)
17 Jun 2008, 19:36
#13
albertsavage avatar

albertsavage

New Zenner

Join Date:
Feb 2008
Posts:
27
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

Yeah, I think you have the old one developed by Netsparx. It was a pain for me so I just rewrote the entire thing. You can find it in the downloads section:

http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=918

I added, modified, you name it. I just pretty much rewrote the whole thing to handle a lot of new stuff.

My newest version description starts:
This is a very adapted version of the prior versions because it has 3 major improvements:


I recommend my version (for obvious reasons).

Albert

JeremyToaster:

Hey Albert,
I must just have an old version of your script or something, because the script I have exports only these details

Customers
Address Book
Categories
Category Descriptions
Products
Product Descriptions
Directory Structure
Products Options
Products Options Value
Products Options Values To Products Options
Products Attributes
Specials
Reviews
Review Descriptions


And that's it, there is no exportation of Orders anywhere. That's why I was copying your format for "Customers" and just replacing everything with "Orders" for corresponding tables in OsC and ZenCart.

If you have a new script that exports Orders, Past, Current, Pending, Shipped, etc, please point me to it as that would be great ! and my hacking would be unnecessary :)
17 Jun 2008, 19:44
#14
jeremytoaster avatar

jeremytoaster

New Zenner

Join Date:
Jan 2008
Posts:
8
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

Nice!
Thanks a lot Albert.
Now I just have to wait for the Drupal module to be finished and I can get this site done!

Thanks so much for clearing things up for me, sorry if I was making things confusing!

Jeremy
17 Jun 2008, 21:30
#15
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Posts:
775
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

For my first post in this forum I just wanted to say Thanks Albert your code worked :smile:

With that said I was trying to modify your code to convert the manufacturer tables.

I got it to half work because I ran into manufacturer_id field which is an auto increment field.
The issue is that all the stores products have the manufacturer id in there record. So over the years adding and deleting manufacturers have left the osc manufacturer_id field non-sequential. So what I need is to convert the osc value in manufacturer_id field unchanged/raw.

I have posted the code that I am working on for reference. You might know the sql command that will allow the insert of the true value of manufacturer id and not the auto increment value.

Your help would be appreciated.

$connected = mysql_connect($source_db_host, $source_db_username, $source_db_password);
$dataopened = mysql_select_db($source_db);

if ($connected) {
	echo "Connected Database Server<br>";
} else {
	echo mysql_error();
	exit;
}
if ($dataopened) {
	echo "Database Opened<br><br><br>";
} else {
	echo mysql_error();
	exit;
}


// Get row id before insert Not used yet
function get_current_insert_id($zen_table)
{
    $q = "SELECT LAST_INSERT_ID() FROM $zen_table";
    return mysql_num_rows(mysql_query($q)) + 1;
}

$query_manufactures = "SELECT * FROM " . $source_db_table_prefix . "manufacturers";
$manufactures = mysql_query($query_manufactures);
$i = 0;
echo 'exporting manufactures ';
while ($export_record = mysql_fetch_assoc($manufactures)) {

	$import_manufactures[$i]['manufacturers_id'] =  $export_record['manufacturers_id'];
	$import_manufactures[$i]['manufacturers_name'] =  mysql_real_escape_string($export_record['manufacturers_name']);
	$import_manufactures[$i]['manufacturers_image'] =  $export_record['manufacturers_image'];
	$import_manufactures[$i]['date_added'] =  $export_record['date_added'];
	$import_manufactures[$i]['last_modified'] =  $export_record['last_modified'];
	$i++;
	echo 'GOod.';

}
mysql_free_result($manufactures);

echo '<br><br>';

$query_manufacturers_info = "SELECT * FROM " . $source_db_table_prefix . "manufacturers_info";
$manufacturers_info = mysql_query($query_manufacturers_info);
$i = 0;
echo 'exporting manufacturers info ';
while ($export_record = mysql_fetch_assoc($manufacturers_info)) {
      $import_manufacturers_info[$i]['manufacturers_id'] = mysql_real_escape_string($export_record['manufacturers_id']);
      $import_manufacturers_info[$i]['languages_id'] = mysql_real_escape_string($export_record['languages_id']);
      $import_manufacturers_info[$i]['manufacturers_url'] = mysql_real_escape_string($export_record['manufacturers_url']);
      $import_manufacturers_info[$i]['url_clicked'] = mysql_real_escape_string($export_record['url_clicked']);
      $import_manufacturers_info[$i]['date_last_click'] = mysql_real_escape_string($export_record['date_last_click']);
	$i++;
	echo '.oO';
}
mysql_free_result($manufacturers_info);

echo '<br><br>';
mysql_close($connected);


$connected = mysql_connect($target_db_host, $target_db_username, $target_db_password);
$dataopened = mysql_select_db($target_db);

echo '<br><br>';

echo 'importing manufacturers <br>';
mysql_query("TRUNCATE `" . $target_db_table_prefix . "manufacturers`");

while (list($i, ) = each($import_manufactures)) {
	$insert_manufacturers = "INSERT INTO " . $target_db_table_prefix . "manufacturers SET
	manufacturers_id = '" . $import_manufacturers[$i]['manufacturers_id'] . "', 
	manufacturers_name = '" . $import_manufacturers[$i]['manufacturers_name'] . "', 
 	manufacturers_image = '" . $import_manufacturers[$i]['manufacturers_image'] . "', 
 	date_added = '" . $import_manufacturers[$i]['date_added'] . "', 
 	last_modified = '" . $import_manufacturers[$i]['last_modified'] . "' 
	";
	echo 'Insert record<br>';
	$success = mysql_query($insert_manufacturers);
	if (!$success) { echo mysql_error(); exit;}
	echo 'Oo.';
}

echo '<br><br>';

echo 'clearing manufacturers_info';
echo '<br><br>';
mysql_query("TRUNCATE `" . $target_db_table_prefix . "manufacturers_info`");
echo 'importing manufacturers_info';
while (list($i, ) = each($import_manufacturers_info)) {
	$insert_manufacturers_info = "INSERT INTO " . $target_db_table_prefix . "manufacturers_info SET
      manufacturers_id = '" . $import_manufacturers_info[$i]['manufacturers_id'] . "', 
      languages_id = '" . $import_manufacturers_info[$i]['languages_id'] . "', 
      manufacturers_url = '" . $import_manufacturers_info[$i]['manufacturers_url'] . "', 
      url_clicked = '" . $import_manufacturers_info[$i]['url_clicked'] . "', 
      date_last_click = '" . $import_manufacturers_info[$i]['date_last_click'] . "'
	";
	$success = mysql_query($insert_manufacturers_info);
	if (!$success) { echo mysql_error(); exit;}
	echo '.';
}

echo '<br><br>';

echo '<br><br>';

mysql_close($connected);

echo '<br><br><br>All Done';

?>
17 Jun 2008, 23:08
#16
albertsavage avatar

albertsavage

New Zenner

Join Date:
Feb 2008
Posts:
27
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

Skip,

I just wrote myself a little macro to get all of the right fields in the right place some months ago. I'll see if I can dig it out if I can find it later and apply it to that table.

However, it won't matter whether the field is auto_increment or not on source or destination. The script is intended to pretty much "copy_paste" the data from one table to another, so it does not "auto increment" anything. There is no transformation going on. This is important to consider since it's a garbage_in-garbage_out script.

Your script at first glance looks good and you should test it on a test database. I have since dismantled my test database, and I didn't have any manufacturersto test it on to begin with anyway. If you do add it, I would add it to the products script since that's the natural location for it. Feel free to upload your first contribution if you do (hey, it's open source).

Albert

skipwater:

For my first post in this forum I just wanted to say Thanks Albert your code worked :smile:

With that said I was trying to modify your code to convert the manufacturer tables.

I got it to half work because I ran into manufacturer_id field which is an auto increment field.
The issue is that all the stores products have the manufacturer id in there record. So over the years adding and deleting manufacturers have left the osc manufacturer_id field non-sequential. So what I need is to convert the osc value in manufacturer_id field unchanged/raw.

I have posted the code that I am working on for reference. You might know the sql command that will allow the insert of the true value of manufacturer id and not the auto increment value.

Your help would be appreciated.

$connected = mysql_connect($source_db_host, $source_db_username, $source_db_password);
$dataopened = mysql_select_db($source_db);

if ($connected) {
	echo "Connected Database Server<br>";
} else {
	echo mysql_error();
	exit;
}
if ($dataopened) {
	echo "Database Opened<br><br><br>";
} else {
	echo mysql_error();
	exit;
}


// Get row id before insert Not used yet
function get_current_insert_id($zen_table)
{
    $q = "SELECT LAST_INSERT_ID() FROM $zen_table";
    return mysql_num_rows(mysql_query($q)) + 1;
}

$query_manufactures = "SELECT * FROM " . $source_db_table_prefix . "manufacturers";
$manufactures = mysql_query($query_manufactures);
$i = 0;
echo 'exporting manufactures ';
while ($export_record = mysql_fetch_assoc($manufactures)) {

	$import_manufactures[$i]['manufacturers_id'] =  $export_record['manufacturers_id'];
	$import_manufactures[$i]['manufacturers_name'] =  mysql_real_escape_string($export_record['manufacturers_name']);
	$import_manufactures[$i]['manufacturers_image'] =  $export_record['manufacturers_image'];
	$import_manufactures[$i]['date_added'] =  $export_record['date_added'];
	$import_manufactures[$i]['last_modified'] =  $export_record['last_modified'];
	$i++;
	echo 'GOod.';

}
mysql_free_result($manufactures);

echo '<br><br>';

$query_manufacturers_info = "SELECT * FROM " . $source_db_table_prefix . "manufacturers_info";
$manufacturers_info = mysql_query($query_manufacturers_info);
$i = 0;
echo 'exporting manufacturers info ';
while ($export_record = mysql_fetch_assoc($manufacturers_info)) {
      $import_manufacturers_info[$i]['manufacturers_id'] = mysql_real_escape_string($export_record['manufacturers_id']);
      $import_manufacturers_info[$i]['languages_id'] = mysql_real_escape_string($export_record['languages_id']);
      $import_manufacturers_info[$i]['manufacturers_url'] = mysql_real_escape_string($export_record['manufacturers_url']);
      $import_manufacturers_info[$i]['url_clicked'] = mysql_real_escape_string($export_record['url_clicked']);
      $import_manufacturers_info[$i]['date_last_click'] = mysql_real_escape_string($export_record['date_last_click']);
	$i++;
	echo '.oO';
}
mysql_free_result($manufacturers_info);

echo '<br><br>';
mysql_close($connected);


$connected = mysql_connect($target_db_host, $target_db_username, $target_db_password);
$dataopened = mysql_select_db($target_db);

echo '<br><br>';

echo 'importing manufacturers <br>';
mysql_query("TRUNCATE `" . $target_db_table_prefix . "manufacturers`");

while (list($i, ) = each($import_manufactures)) {
	$insert_manufacturers = "INSERT INTO " . $target_db_table_prefix . "manufacturers SET
	manufacturers_id = '" . $import_manufacturers[$i]['manufacturers_id'] . "', 
	manufacturers_name = '" . $import_manufacturers[$i]['manufacturers_name'] . "', 
 	manufacturers_image = '" . $import_manufacturers[$i]['manufacturers_image'] . "', 
 	date_added = '" . $import_manufacturers[$i]['date_added'] . "', 
 	last_modified = '" . $import_manufacturers[$i]['last_modified'] . "' 
	";
	echo 'Insert record<br>';
	$success = mysql_query($insert_manufacturers);
	if (!$success) { echo mysql_error(); exit;}
	echo 'Oo.';
}

echo '<br><br>';

echo 'clearing manufacturers_info';
echo '<br><br>';
mysql_query("TRUNCATE `" . $target_db_table_prefix . "manufacturers_info`");
echo 'importing manufacturers_info';
while (list($i, ) = each($import_manufacturers_info)) {
	$insert_manufacturers_info = "INSERT INTO " . $target_db_table_prefix . "manufacturers_info SET
      manufacturers_id = '" . $import_manufacturers_info[$i]['manufacturers_id'] . "', 
      languages_id = '" . $import_manufacturers_info[$i]['languages_id'] . "', 
      manufacturers_url = '" . $import_manufacturers_info[$i]['manufacturers_url'] . "', 
      url_clicked = '" . $import_manufacturers_info[$i]['url_clicked'] . "', 
      date_last_click = '" . $import_manufacturers_info[$i]['date_last_click'] . "'
	";
	$success = mysql_query($insert_manufacturers_info);
	if (!$success) { echo mysql_error(); exit;}
	echo '.';
}

echo '<br><br>';

echo '<br><br>';

mysql_close($connected);

echo '<br><br><br>All Done';

?>
22 Jun 2008, 10:40
#17
centec2b avatar

centec2b

New Zenner

Join Date:
May 2008
Posts:
52
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

Albert, All

Thank you for creating this download, it makes life a lot easier when your migrating from OSC to Zen

I have successfully used Albert's latest iteration of the contribution and am now trying to add in manufacturers and also the meta tags for categories and products.

Both pieces of code complain about the same error. Taking the manufacturers code;

importing manufacturersYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6


I have banged this about for several hours and cannot see what I am doing wrong. It is probably a minor item but...

I would be very grateful for any suggestions as to where to take this

Below is the code for taking the data out of OSC

$query_manufacturers = "SELECT * FROM " . $source_db_table_prefix . "manufacturers";
$manufacturers = mysql_query($query_manufacturers);
$i = 0;
echo 'exporting manufacturers';
while ($export_record = mysql_fetch_assoc($manufacturers)) {
	$import_manufacturers[$i]['manufacturers_id'] =  mysql_real_escape_string($export_record['manufacturers_id']);
	$import_manufacturers[$i]['manufacturers_name'] =  mysql_real_escape_string($export_record['manufacturers_name']);
	$import_manufacturers[$i]['manufacturers_image'] =  mysql_real_escape_string($export_record['manufacturers_image']);
	$import_manufacturers[$i]['date_added'] =  mysql_real_escape_string($export_record['date_added']);
	$import_manufacturers[$i]['last_modified'] =  mysql_real_escape_string($export_record['last_modified']);
	$i++;
	echo '.';
}
mysql_free_result($manufacturers);


And this is the code for putting into Zen

echo 'importing manufacturers';
mysql_query("TRUNCATE `" . $target_db_table_prefix . "manufacturers`");
while (list($i, ) = each($import_manufacturers)) {
	$insert_manufacturers = "INSERT INTO " . $target_db_table_prefix . "manufacturers SET
	manufacturers_id = '" . $import_customer[$i]['manufacturers_id'] . "', 
	manufacturers_name = '" . $import_customer[$i]['manufacturers_name'] . "', 
 	manufacturers_image = '" . $import_customer[$i]['manufacturers_image'] . "', 
 	date_added = '" . $import_customer[$i]['date_added'] . "', 
 	last_modified = '" . $import_customer[$i]['last_modified'] . "', 
 	";
	$success = mysql_query($insert_manufacturers);
	if (!$success) { echo mysql_error(); exit;}
	echo '.';
}


Thank you

A very perplexed Centec2b
22 Jun 2008, 13:59
#18
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Posts:
775
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

I have uploaded a update to Albert's version 1.2 it has the Manufacturers section in it.
Try running version 1.3 and see if the error is still there. Version 1.3

If there is an error post your MySql version.
22 Jun 2008, 22:53
#19
centec2b avatar

centec2b

New Zenner

Join Date:
May 2008
Posts:
52
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

skipwater:


Try running version 1.3 and see if the error is still there.


Skipwater

Thank you.

When I compared the two and then reread the thread - duuhhhhh!

typos typos typos in my code.

I have just rerun after correcting and it worked like a dream.

The moral of the tale is dont sit up till the early hours and expect sense to prevail!

Thank you again

Centec2b
23 Jun 2008, 23:27
#20
centec2b avatar

centec2b

New Zenner

Join Date:
May 2008
Posts:
52
Plugin Contributions:
0

Re: OsCommerce Data Importer - Errors

Hi Folks

Following earlier dialogues with Skipwater, I am now trying to include the metatags that appear in OSC categories_description and transfer them to the separate table meta_tags_categories_description

I have mimicked the code, but I must be missing some refinement as whilst the code says I have exported the data, there is no data imported into Zen.

I do not get error messages of any description

I would be grateful for any pointers on how I can solve this

The code excerpts are

From OSC
/* start of export of categories_meta_tags */
$query_categories_meta_tags = "SELECT * FROM " . $source_db_table_prefix . "categories_description";
$categories_meta_tags = mysql_query($query_categories_meta_tags);
$i = 0;
echo 'Exporting Categories Meta Tags...';
while ($export_record = mysql_fetch_assoc($categories_meta_tags)) {
      $import_categories_meta_tags[$i]['categories_id'] = mysql_real_escape_string($export_record['categories_id']);
      $import_categories_meta_tags[$i]['language_id'] = mysql_real_escape_string($export_record['language_id']);
	  $import_categories_meta_tags[$i]['categories_htc_title_tag'] = mysql_real_escape_string($export_record['categories_htc_title_tag']);
      $import_categories_meta_tags[$i]['categories_htc_desc_tag'] = mysql_real_escape_string($export_record['categories_htc_desc_tag']);
      $import_categories_meta_tags[$i]['categories_htc_keywords_tag'] = mysql_real_escape_string($export_record['categories_htc_keywords_tag']);
$i++;
 echo '.';
}
mysql_free_result($categories_meta_tags);
 
echo ' Done '.$i.' Records Exported<br>';
/* end of export of categories_meta_tags */




Insert in Zen
/* start of import of categories meta tags */
$ii=0;
echo 'Importing Categories Meta Tags...<br>';
mysql_query("TRUNCATE `" . $target_db_table_prefix . "meta_tags_categories_description`"); 
while (list($i, ) = each($import_categories_meta_tags)) {
$insert_meta_tags_categories_description = "INSERT INTO " . $target_db_table_prefix . "meta_tags_categories_description SET 
	categories_id = '" . $import_categories_meta_tags[$i]['categories_id'] . "', 
	language_id = '" . $import_categories_meta_tags[$i]['language_id'] . "', 
	metatags_title = '" . $import_categories_meta_tags[$i]['categories_htc_title_tag'] . "', 
	metatags_keywords = '" . $import_categories_meta_tags[$i]['categories_htc_keywords_tag'] . "',
	metatags_description = '" . $import_categories_meta_tags[$i]['categories_htc_desc_tag'] . "'
";
 $success = mysql_query($insert_meta_tags_categories_description);
 if (!$success) { echo mysql_error(); exit;}
 echo '.';
}
echo ' Done '.$ii.' Records Imported<br>';
/* end of import of categories meta tags  */



Thank you

Centec2b