6 replies [Last post]
ñull@drupal.org's picture
Offline
Joined: 01/26/2009
Juice: 114
Was this information Helpful?

I tried yesterday to import or rather transform ec image nodes to uc product nodes with image field by using the script as shown in this thread:

http://drupal.org/node/201983

This worked partly. What is missing is the corresponding table row in uc_product of course. Most of the column values of this table I can get from the ec tables except one: unique_hash. How is that one generated?

ñull@drupal.org's picture
Offline
Joined: 01/26/2009
Juice: 114
Re: Questions related to importing from ec

What about the SN (Product SKU/model.)? In EC it was not obligatory in UC it is. What consequences could it have when I just leave it blank?

ñull@drupal.org's picture
Offline
Joined: 01/26/2009
Juice: 114
Re: Re: Questions related to importing from ec

I left it blank and I hope it won't harm any functionality. If it would harm, please warn me!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Questions related to importing from ec

Not having a SKU will most likely cause problems, since various modules expect there to be one. If I were you, I'd just set the SKU to be the node ID if you don't really need that field for your store.

ñull@drupal.org's picture
Offline
Joined: 01/26/2009
Juice: 114
Re: Re: Re: Re: Questions related to importing from ec

Will be easy enough to do that, thanks for the warning!

ñull@drupal.org's picture
Offline
Joined: 01/26/2009
Juice: 114
Re: Questions related to importing from ec

Looks like I found it.

<?php
$node
->unique_hash = md5($node->vid . $node->nid . $node->model . $node->list_price . $node->cost . $node->sell_price . $node->weight . $node->weight_units . $node->length . $node->width . $node->height . $node->length_units . $node->pkg_qty . $node->default_qty . $node->shippable . time());
?>

so in terms of MySQL that would be something like

CAST(
MD5(
  CONCAT(
   ec_product.vid,ec_product.nid,ec_product.sku,'0.00','0.00',ec_product.price,'0','kg','0','0','0','cm','1','1','1',
   (NOW()+0)
  )
)
AS CHAR
)

Attached the script I used to migrate image products to the default UC Product node with active CCK image field.

AttachmentSize
image2uc_products_migrateV2.php 3.86 KB
ñull@drupal.org's picture
Offline
Joined: 01/26/2009
Juice: 114
Updated script V2

The updated script V2 (see above) will only migrate images that are actually products and leave normal image nodes untouched. The node id is inserted as SKU when the field is blank in ec_product.