You are hereBlogs / willhall's blog / Migration of OsCommerce Products to Node Products: 2

Migration of OsCommerce Products to Node Products: 2


By willhall - Posted on 09 March 2010

Following the uploading of products to one product database within phpmyadmin/mysql root, you will now have a Drupal database with a new table named 'products' within it. You can then use the table wizard module to expose the table to the migrate module and draw relationships between the 'products' and 'uc_products' database table.

I have added another little script which runs almost the same process as the migrate module, however, this may need to be edited to run successfully:

<?php
$ubercart_database = 'uberdrupal_tensor';

mysql_connect('localhost', 'admin', 'sheik') or die('Cannot connect to MySql');
mysql_select_db($ubercart_database) or die('Cannot connect to database');

$sql_attributes = 'select * from products';
$query_attributes = mysql_query($sql_attributes);

$i = 1; //starting nid

while($result_attributes = mysql_fetch_assoc($query_attributes)){
$model = $result_attributes['products_model'];
$price = $result_attributes['products_price'];
$weight = $result_attributes['products_weight'];
$length = $result_attributes['products_length'];
$width = $result_attributes['products_width'];
$height = $result_attributes['products_height'];

$update_uc_products = "update uc_products set model = '$model', list_price = $price, cost = $price, sell_price = $price, weight = $weight, weight_units = 'kg', length = $length, width = $width, height = $height, length_units = 'cm', pkg_qty = 1, default_qty = 1, ordering = 1, shippable = 1 where nid = $i";
echo $i;
$i++;

if(!empty($update_uc_products)){
echo $update_uc_products.'';
mysql_query($update_uc_products);
}
}

@willhallonline

  • does anyone know any good php courses I can send a beginner/intermediate developer on? 1 week 5 days ago
  • adobe gone... GIMP in... hmm maybe I'll just pass design to someone else to handle 1 week 6 days ago
  • removing adobe cs4... why? because I just don't use it 1 week 6 days ago
  • Working on my music site tonight. New release soon (its only been nearly 2 years) 2 weeks 2 days ago
  • hmm, getting quite a bit of spam through my site today... how frustrating 2 weeks 2 days ago