Dear drupal 5 to our colleague did support the importation of product into ubercart http://www.drupal.ru/node/17859 (not upgrade module). There was a pressing ubercart for drupal 6, please turn on the module support imports for ubercart 2.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

doughold’s picture

I would love to see importing enabled as I have a client I am developing a site for and was just going to hack my way around until I made something that was functional for them. I have to finish the site in the next week so I would LOVE it if this could be done soon.

Edit: I am currently working on the import module for UC. I realize node import is still highly under development, but I have the basics working on the import. I will post it when it is further along in development for review.

Robrecht Jacques’s picture

Version: 6.x-1.0-rc2 » 6.x-1.0-rc3
Status: Active » Postponed (maintainer needs more info)

What exactly do you wish to import? uc_product? Can you attach a sample CSV file (10 rows or so) to easy testing? Thanks.

Gumk-1’s picture

FileSize
25.28 KB

Here, please. You can also watch a video like this to work on drupal 5 _http://tochka-starta.ru/big_files/node_import_for_uc.swf.

warrenscott’s picture

Version: 6.x-1.0-rc3 » 6.x-1.x-dev
FileSize
1.94 KB

Here is the file I have been trying. Can get to mapping fine but the proper mapping fields are not available

doughold’s picture

FileSize
3.54 KB

I used this modified version of the D5/UC1 code and was able to import a bunch of products. It only has the basic fields, and no attributes.

snepa’s picture

doughold,

Are you working with:

Robrecht Jacques' node_import-6.x-1.0-rc3 version (http://drupal.org/project/node_import)

or

tanoshimi's node_import-6.x-dev version (http://drupal.org/node/207738)?

I'd like to give your modified uc_product.inc file a try. I desperately need to import products (don't need attributes) into Ubercart 6.x-2.0-beta4/Drupal 6.9.

snepa

snepa’s picture

doughold,

Sorry. I've gotten a bit turned around trying to follow the threads.

This discussion is identified with Jacques' version - node_import-6.x-1.x-dev.

rc3 or 1.x-dev?

I think from reading Robrecht's responses on other threads that rc4 is close. I'm not savvy or experienced enough to be working with dev versions yet.

snepa

ferrangil’s picture

Subscribing... very interested in node_import for ubercart 2 and drupal 6.x

doughold’s picture

Hey, sorry for not posting this earlier, I am using the rc3 version, Drupal 6.9, and UC Beta 4

BeatnikDude’s picture

Thanks all, Node Import support for Ubercart 2 and Drupal 6.x would be very useful.

I am using: PHP 5.2.6, D6.9, Ubercart 6.x-2.0-beta4, Node Import module 6.x-1.0-rc3
With the uc_product.inc include from doughold @ #5 I was able to import Ubercart products from a CSV. I did not import images.

drdmmr’s picture

I set up my D6 site with Ubercart 2.x and I cannot get the products to import using the node_import: I spent some time today reading others posts about the same problem. I am happy to work on a solution, but I don't want to do parallel dev work on this.

I'm going to research all that occurs (in DB) when I add a product and see if I can come up with a batch solution. If anyone can put me in touch with anyone that may have some insight/interest in this effort, please hook us up.

lbrown’s picture

Subscribing.

I have been watching the node import thread for ubercart 2 support for quite some time. I am anxiously awaiting it in order to upload a few hundred products and photos.

A paypal donation will be made upon support of Ubercart 2 with drupal 6.9

Thank you to all who are working on this module.

Lena Brown

drdmmr’s picture

Title: node import and ubercart 2 » success using PHP, node_import & ubercart 2
Component: User interface » Code

I am using D6.9 and UC 2.0-beta4

This is a workaround. I've successfully imported a CSV file of products and got images to show up in my catalog.

This is my procedure:

Copy all images to sites/default/files
import data from CSV file, using the node_import (images and taxonomy* fail as expected).
*I just leave this out of the import to avoid the slew of errors.

Using a 'Drupal bootstrapped' PHP script, I convert my CSV file into an associative array (by model). I read the uc_products table, 1 row at a time, (db_fetch_object) gathering the model, nid and vid for each record.
Using the model, I get the image field from my CSV data.
After determining the mime and filesize, I insert all this (along with the path) into the files table and fetch the corresponding fid.
With all this data, I update the content_field_image_cache table:
nid = $nid
vid = $vid
field_image_cache_list = 0
field_image_cache_fid = $fid
field_image_cache_data = 'a:0:{}';

and call drupal_flush_all_caches();

When I refresh my Drupal site, I see my catalog with all my images!

I'm fairly new to this stuff and I'm sure there's a much more "Drupal" approach than this hack (which I will work on forthwith). I needed this functionality, my site appears to work fine, and I wanted to share my success with other folks who need this as well.

I'm now working on getting the taxonomy importing as well.

Doug

drdmmr’s picture

Title: success using PHP, node_import & ubercart 2 » node_import & ubercart 2
Component: Code » User interface

Using the same Drupal bootstrapped code, I add the taxonomy terms from the CSV file for each node (with hierarchy). There is still some manual labor involved that I am working on automating, but basically I do have a procedure for importing products from a CSV file (with images and hierarchical taxonomy) in Ubercart 2.

hutch’s picture

Subscribed: a very interesting development, I would like to see your code so far, I might be able to chip in here ;-)

doughold’s picture

FYI: The new dev snapshot contains code for product imports (including images!), but I cannot get taxonomies to import as of yet.

I get these errors:

* warning: mb_strlen() expects parameter 1 to be string, array given in /var/clients/client0/web22/web/includes/unicode.inc on line 404.
* warning: mb_strlen() expects parameter 1 to be string, array given in /var/clients/client0/web22/web/includes/unicode.inc on line 404.
* warning: mb_strlen() expects parameter 1 to be string, array given in /var/clients/client0/web22/web/includes/unicode.inc on line 404.
* warning: mb_strlen() expects parameter 1 to be string, array given in /var/clients/client0/web22/web/includes/unicode.inc on line 404.
* warning: mb_strlen() expects parameter 1 to be string, array given in /var/clients/client0/web22/web/includes/unicode.inc on line 404.
* warning: mb_strlen() expects parameter 1 to be string, array given in /var/clients/client0/web22/web/includes/unicode.inc on line 404.
* warning: mb_strlen() expects parameter 1 to be string, array given in /var/clients/client0/web22/web/includes/unicode.inc on line 404.
* warning: mb_strlen() expects parameter 1 to be string, array given in /var/clients/client0/web22/web/includes/unicode.inc on line 404.
* Manufacturer (key=9, weight=0) field is required.
* Room (key=7, weight=0) field is required.
* Wood Type (key=8, weight=0) field is required.
* Category is required.

Where the last four lines are Vocabularies.

Edit: I deleted my vocabularies and re-created them and the errors are no more! Since this might be a bug still I will leave my errors up.

cjdavis’s picture

subscribing. We have a huge need for node_import with UC2, it sounds as if we should be testing the latest dev release.

Robrecht Jacques’s picture

Status: Postponed (maintainer needs more info) » Fixed

Ubercart 2 (uc_product only) has been added to CVS. It will be included in the next release -rc4.

For the taxonomy problem ... I'll need to investigate so I've opened a new issue: http://drupal.org/node/383926

cjdavis’s picture

That is fantastic news, a thousand thank yous.

We will have several thousand items to import over the next couple of months, with a couple dozen CCK fields, so it will get a good testing. So far with the first couple of items, it is successful.

Thank you!

hutch’s picture

I fetched the CVS version and it imports fine.
However I want to be able to either skip or update any records that already exist as defined by the 'model' field, with something like

$row = db_fetch_array(db_query("SELECT nid, count(model) AS ct FROM {uc_products} WHERE model = '%s'", array($node->model)));
if ( $row['ct'] > 0 ) {
  // skip or better still UPDATE on $row['nid']
}

Any ideas welcome

Robrecht Jacques’s picture

I know people are waiting for update capabilities, but this is not as easy as it seems:

1. How does one know what node to update? For Ubercart the SKU is probably the way to go, but for other node types, one would need Title or some other CCK field. So there is a need to set that as an option. Note that this is the easy part.

2. What exactly needs to be done? Does one want to remove all modifications made by web? Does one want to add the submitted values or totally replace them? Or merge? Etc. This is the hard part.

I am investigating on how to do it, but at the moment I want to get a 1.0 release out that works reliable with importing, and I need to postpone updating until that works.

hutch’s picture

I understand the need to get importing functioning first, I will knock up a bootstrap script for my needs in the meantime.

ferrangil’s picture

Yes, please, first focus on node_import and not node_update :)

By the way, there are options for updating, for example, the prices of your products in a easy way:

If you have an excel file with two columns, the SKU and the new price, just add the following 'text' and then save all the lines together as a .sql and run that file on phpmyadmin or whatever you have to access the DB.

Commands should look like:
update uc_products set sell_price='30.000' where model='ARL0014'

Where ARL0014 is the SKU of your product and 30 is the new price. This a really fast method to update several hundred prices in a batch mode. And asking for a 2 column excel file with the new prices is an easy tasks that non-developers will be able to do straight away.

doughold’s picture

Updating is definitely key when talking about managing products. However, I agree that a stable primary release should be the focus. Thanks for all of your efforts Robrecht, they are greatly appreciated!

zeezhao’s picture

Hi. When I run with the very latest node_import-6.x-1.x-dev.tar.gz (February 27, 2009 - 00:15) I get this error after "Set file options (step 3 of 8)", choosing the appropriate format (pipe delimited), and pressing the next button:

Fatal error: Call to undefined function uc_product_node_is_product() in ....\node_import\supported\ubercart\uc_product.inc on line 15

Please is there something else I am missing?

I assume that this version is the latest in CVS?

Thanks

zeezhao’s picture

I updated ubercart to latest one: ubercart-6.x-2.0-beta4.tar.gz

Then moved past that stage to "Map file columns (step 4 of 8)". After pressing next button, got this error:

Fatal error: Call to undefined function date_timezone_names() in ...\modules\node_import\node_import.inc on line 308

Running drupal 6.6 with the very latest node_import-6.x-1.x-dev.tar.gz (February 27, 2009 - 00:15)

ferrangil’s picture

I don't think this is going to solve your problem, but upgrade to Drupal 6.10 asap.
I'm importing products and images with no problems right now.

zeezhao’s picture

It appears to be related to a missing Date_api module. Since I was upgrading from an old version, it did not complain during upgrade.

[edit]
- Resolved by installing date module. Now works. thanks.
- only issue is that I could not get taxonomy to load automatically from the same file of products... Maybe I did not understand usageof this...

zeezhao’s picture

Please can someone confirm if taxonomy will now load automatically from the same file of as products i.e. its a field in the products file?

Even though latest code seems to suggest it works, I could not load any taxonomy/vocabulary. And looking at the threads I am not sure if this is still outstanding. Thanks for your help.

drdmmr’s picture

I too cannot get taxonomy to load as part of node import (pointing a field in the products file to Vocabulary:Catalog); in fact, I get errors when I try:

warning: mb_strlen() expects parameter 1 to be string, array given in [path to drupal]\includes\unicode.inc on line 404.

I haven't investigated this in the code. Like everyone else, I'm waiting for this aspect of node_import to be working. In the meantime, however I use a Drupal-bootstrapped script to handle importing the taxonomy from the same CSV file I use for node_import (creating the hierarchy in the process), which gets me where I need to be.

I am using D6.10 Ubercart 6.x-2.0-beta4, node_import 6.x-1.x-dev (2009-Feb-26)

Doug

JackThompson’s picture

Any progress on this? Will this work for digital goods? if so, how to tell Uber about the location of the digital goods?

mynode’s picture

Are people still looking for update capability with node import? I have implemented a patch to uc_product.module that allows me to update existing products when importing products with node import.

It matches the nodes on the uc_product field 'model' which is interpreted in Drupal's ubercart module as SKU. SKU should be semantically correct for a catalog item.

I'm using:
Drupal 6.10
node_import 6.x-1.0-rc4
ubercart 6.x-2.0-beta5

The patch defines a nodeapi hook for uc_product. It is still very much an alpha so be careful.

/*
 * Added by mynode to allow products to be updated
 * with bulk import.
 * The function matches the imported node's 'SKU' with the 'model' field
 * stored for the uc_product.
 */
function uc_product_nodeapi(&$node, $op, $teaser, $page) {
  if($op=='presave' && isset($node->log) 
     && $node->log == 'Imported with node_import.' && isset($node->model)) {
    $result = db_query("SELECT nid, vid, model FROM uc_products where model='".$node->model."' ORDER BY vid DESC LIMIT 1");
    if($prod = db_fetch_object($result)) {
      $node->nid = $prod->nid;
      $node->vid = $prod->vid;
    }
  }
}
asoka250’s picture

Is the issue resolved as yet?. drdmmr, can you give the workaround process that you did for importing hierarchical taxonomies from the csv file along with the products. I am not sure what are all the tables I need to deal with inorder to do it in the manual way.

xurizaemon’s picture

@mynode, great work. Thankyou!

I posted a Drupal5 / Ubercart 1.x version of your nodeapi hook at http://www.ubercart.org/forum/development/9923/node_import_update

Note that your alpha nodeapi code above may be open to unexpected contents in the CSV file as it doesn't do any escaping for SQL. Try this instead:

      $sql = "SELECT nid, vid, model FROM {uc_products} where model='%s' ORDER BY vid DESC LIMIT 1" ;
      $result = db_query($sql, $node->model);
 

Also, it's not necessary to add this to uc_product module (though that's a good place for it). I've added this to a custom module of my own, which avoids having to maintain a patched version of uc_product.

parul’s picture

Version: 6.x-1.x-dev » 6.x-1.0-rc4
Category: feature » bug
Status: Fixed » Needs work

I am using Drupal 6.9 with Ubercart beta 4. I installed node_import 6.x-rc4.
When I create a new import, for products, I see the CCK field very fine, preview works good too, but instead of going to Start Import page after Preview, the module takes me back to the starting page. The import doesn't get saved anywhere or imported either.

I have three CCK fields defined for my product - Size, Media, and Image (ImageField)

jork_zijlstra@hotmail.com’s picture

I am using Drupal 6.10 with the Ubercart Drupal 6 - Ubercart 2.x and Node import 6.x-1.0-rc4 for the product import.
The problem that I got is that node import gave the error warning: mb_strlen() expects parameter 1 to be string.

So I went debugging and found out that the problem is with hierarchy for the catalog.

This is the line that causes the problem in node_import.inc line 553 (closeby)
$fieldvalues[$i] = strlen($value) > 0 ? array_map('trim', explode($hseparator, $value)) : array($value);

$fieldvalues[$i] will contain an array of terms. Only when importing it doesn't expect an array within the $fieldvalues[$i], but $fieldvalues[$i] needs to be the array.
So replace
$fieldvalues[$i] = strlen($value) > 0 ? array_map('trim', explode($hseparator, $value)) : array($value);
for
$fieldvalues = strlen($value) > 0 ? array_map('trim', explode($hseparator, $value)) : array($value);

My next problem is that when importing the product with the above fix, the product will be connected to ALL terms. I only want it to be connected to the last.
So I suspect that the seperators || and >> do not work correctly.

To go around this replace the original line with this.
$fieldvalues = strlen($value) > 0 ? $fieldvalues = array(array_pop(array_map('trim', explode($hseparator, $value)))) : $fieldvalues = array($value);

Keep in mind that these are quick fixes that works for me.

kilrizzy’s picture

@jork Thank you this solution fixed my issue!

When trying either of the two fixes for me it only selects the last item. Is there anything I may be missing to get it to select all terms?

quadmin’s picture

Errors
SKU field is required.

Drupal version: 6.10
PHP version: 5.2.6
node_import 6.x-1.0-rc4

error file in attachment:

jork_zijlstra@hotmail.com’s picture

@kilrizzy

Don't do this part of the patch.

To go around this replace the original line with this.
$fieldvalues = strlen($value) > 0 ? $fieldvalues = array(array_pop(array_map('trim', explode($hseparator, $value)))) : $fieldvalues = array($value);

Normally it connects to all terms. The above code only lets it connect to the last one.

Prasad Shir’s picture

subscribing

samhodge1972’s picture

FileSize
851 bytes

I am having the same error

* warning: mb_strlen() expects parameter 1 to be string, array given in C:\xampp\htdocs\palas_import\includes\unicode.inc on line 404.
* warning: mb_strlen() expects parameter 1 to be string, array given in C:\xampp\htdocs\palas_import\includes\unicode.inc on line 404.

The repro steps are pretty straightforward

  1. Create a Vocablary called "Food", applied to the "Page" content type
  2. Add a Term "Fruit" to the vocab "Food"
  3. Add a Term "Veg" to the vocab "Veg"
  4. Open up the Node import dialog
  5. point it to the text file hosted at http://www.hodge.net.au/fruitnveg.txt
  6. This is a tab delimited file
  7. Link the "Title" to "Title"
  8. Link the "Content" to "Body"
  9. Link the vocab "Food" to "Type"
  10. Next, Next Next
  11. Error
  12. No taxonomy terms added to the content
Zalatar’s picture

**subscribing**

pancapangrawit’s picture

**subscribing** too :) Would be lovely to have this working!

CKIDOW’s picture

subscribing

domineaux’s picture

Subscribing

junwin’s picture

Hi,

The following value is triggering the error in $values[$fieldname]:

array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(10) "Value"
  }
}

When passing that value to the below line:
$values[$fieldname] = array_filter((array)$values[$fieldname], 'drupal_strlen');

drupal_strlen gets an array as an argument which it is unable to process generating the strlen errors that you see.

Please try the patch let me know if it solves your problem,

JackThompson’s picture

What about importing Digital E-goods. Does anyone care???

terryg-1’s picture

Subscribing

dawick’s picture

For the taxonomy problem; make for multiple tags per vocabulary different columns and set your taxonomy terms as tags. This even works for hierarchal terms by undoing tags agains.

Good luck!

zaphod4269’s picture

Yes, someone please enable importing of digital E-goods!

I have 2900 products i need to import into ubercart. The majority of them have PDFs that can be purchased online...

zaphod4269’s picture

I'm getting the same error when trying to import. The product nodes have no categories assigned.

warning: mb_strlen() expects parameter 1 to be string, array given in /home/toolsfor/public_html/includes/unicode.inc on line 404.

Post #49 seems to be trying to explain a solution, but the broken english is too hard to understand. Can someone translate it into something that makes sense?

and Post #46 seems to have a patch that applies to this error. Has anyone tested it?
[edit]
Tried applying the patch. Got more different errors, so reverted back to the default file.

zaphod4269’s picture

Version: 6.x-1.0-rc4 » 6.x-1.x-dev
Component: User interface » Code

I updated to the latest dev snapshot and now the catalog categories (taxonomy) are coming in with the import.

but a new problem arose...

I tried it with a test CSV file that only has one record in it. It kept looping and importing that one record over and over.

I stopped it after it did 7 loops. In content management, I now have 7 identical products.

and there was also the following error...

* user warning: Unknown column 'file_offset' in 'where clause' query: UPDATE node_import_status SET status = 2, objid = 12 WHERE taskid = 4 AND file_offset = 2438 in /home/toolsfor/public_html/sites/all/modules/node_import/node_import.inc on line 906.
* user warning: Unknown column 'file_offset' in 'field list' query: UPDATE node_import_tasks SET status = 2, file_offset = 3982 WHERE taskid = 4 in /home/toolsfor/public_html/sites/all/modules/node_import/node_import.inc on line 915.

domineaux’s picture

I use the iMacro addin/plugin for firefox.

This is a thread about node_import and I realize my post may not fit, but I saw where someone above had 2900 product items to import.

Just as with node_import your database to import from must be "perfect" every comma, every field has to be perfect.

Getting the import data properly prepared can take days of work to get it ready.

Using the iMacro has it's quirks as well,but you don't get errors that can affect or destroy your mysql.

You can do short runs, and what you enter (wrong or right) you can easily check out or remove within Drupal admin feature.

I found out about the iMacro from another poster on these boards. It was sunshine on a rainy day. LOL

cjdavis’s picture

FileSize
972 bytes

The latest dev version of ubercart has killed product imports again, at step 4 of the wizard you get the same error that zeezhao was seeing in #25 -

Fatal error: Call to undefined function uc_product_node_is_product() in ....\node_import\supported\ubercart\uc_product.inc on line 15

Which is caused by the missing uc_product_node_is_product() function. Add the following to the uc_product.inc file:


/**
 * Check if the node_import $type is a uc product content type.
 *
 * @param $type
 *   String. Node_import $type.
 *
 * @return
 *   FALSE if $type is not a node content type. Otherwise
 *   the node content type.
 */
function uc_product_node_is_product($type) {
  if (strpos($type, 'product') === 0) {
    return TRUE;
  }
  return FALSE;
}

I've attached the entire file. Anybody good at generating a patch, feel free to contribute it..

heyyo’s picture

same error than in #38
SKU field is required at step 7/8

with last Ubercart RC-4

xurizaemon’s picture

@quadmin, @heyyo - try uc_auto_sku (is that the right version? i thought there was a d6 version too?) or add a column in your CSV with some SKU - just make an extra column with a sequential number or other unique code

heyyo’s picture

I have already a SKU column in my CSV, but on step 4/8 SKU is not listed in Content field( but I could only see SKU in "Maps to column")

xurizaemon’s picture

@cjdavis, uc_product_node_is_product() is still in uc_product.module in ubercart-6.x-2.0-rc3 but does appear to have been removed in the latest 2.x-dev version.

the code you posted would only work if your node types were named "product_jelly", "product_tiger", "product_underpants" (we use product node types like "magazine" and "review" and "cd"); it would also wrongly claim the type is a product if the node type is "byproduct" or "productivity" ...

UPDATE: The function has been merged with uc_product_is_product(), which will accept either a node or a string for the product type as its first parameter. Use that function instead of re-adding uc_product_node_is_product().

here's the original function from the current 2.0-rc3 (i'm not sure why this is gone from 2.x-dev, don't see a mention of its removal in CVS messages).

/**
 * Determines whether or not a node type is a product node type.
 *
 * @param $type
 *   The node type to check.
 * @return
 *   TRUE or FALSE indicating whether or not a node type is a product node type.
 */

/* DON'T USE - see comment above for the replacement function 
function uc_product_node_is_product($type) {
  drupal_set_message("DEPRECATED - Please remove the function uc_product_node_is_product() and use uc_product_is_product() instead.");
  return in_array($type, uc_product_types());
}
*/ 
heyyo’s picture

I tried "uc_product_power_tools" ( http://www.ubercart.org/contrib/9566 ) to generate SKU automatically, I still have the same error SKU field is required.

heyyo’s picture

With UC auto SKU I succeeded to import data, but I didn't pay attention that
List price, Cost:, Sell price: were not present in the mapping process like SKU...

Maybe I have the wrong uc_product.inc. Could someone could point me to the last version of this file.
Or my issue is related to uc_product_node_is_product #54 #58

Thanks.

xurizaemon’s picture

@cjdavis, I've spun that function rename off into a separate issue, because this issue has been around for ages and I'd like to get that small patch in fairly speedily.

#555202 - node_import+ubercart - function rename in ubercart-6.x-2.x-rc5 (err: undefined function uc_product_node_is_product())

schwascore’s picture

I'm having the exact same problem as heyyo. I have a SKU field in my csv upload, but there is no option to map it as being the SKU field. List price, cost, sell price are missing as well.

Please help!

nickcaballero’s picture

Status: Needs work » Needs review

Changed the fields array in my uc_product.inc to the fields array in #4's uc_product.inc: worked right away. Also had to modify the _uc_product_node_import_is_product() (this function varies but fulfills the same purpose in all uc_product.inc) to return true at all times.

I first changed the _uc_product_node_import_is_product() which then gave me an error from the node_import.inc in the following statement:

Line 176: $fields[$type][$fieldname] = $fieldinfo = array_merge($defaults, $fieldinfo);

Apparently, $fieldinfo was not an array and hence the array_merge() failed. I looked at #4's uc_product.inc and noticed the extra array. Changed it and the field mapping now appears in step 4. Finally I was able to import :D

nickcaballero’s picture

Status: Needs review » Needs work
TechnoBuddhist’s picture

subscribing

Jakowski-1’s picture

Sicnic, could you maybe post your uc_product.inc file?? I'd like to compare the one I have with yours since yours works and I can't seem to get mine to do so based off your suggestions.

nickcaballero’s picture

This works for me. I have to change the _uc_product_node_import_is_product when I am not importing products otherwise it fails.

<?php
// $Id:$

/**
 * @file
 * Support file for node_import module for Ubercart products (uc_product).
 */

/**
 * Implementation of hook_node_import_fields().
 */
function uc_product_node_import_fields($type) {
  if (_uc_product_node_import_is_product($type)) {
		$fields = array();
    $fields['model'] = array(
      'title' => t('Product: SKU'),
      'group' => t('Product information'),
      'weight' => 1,
    );
    $fields['list_price'] = array(
      'title' => t('Product: List price'),
      'group' => t('Product information'),
      'weight' => 2,
    );
    $fields['cost'] = array(
      'title' => t('Product: Cost'),
      'group' => t('Product information'),
      'weight' => 3,
    );
    $fields['sell_price'] = array(
      'title' => t('Product: Sell price'),
      'group' => t('Product information'),
      'weight' => 4,
    );
    $fields['shippable'] = array(
      'title' => t('Product: Shippable'),
      'group' => t('Product information'),
      'input_format' => 'boolean',
      'weight' => 5,
    );
    $fields['weight'] = array(
      'title' => t('Product: Weight'),
      'group' => t('Product information'),
      'weight' => 6,
    );
    $fields['weight_units'] = array(
      'title' => t('Product: Weight unit'),
      'group' => t('Product information'),
      'allowed_values' => array('lb' => t('Pounds'), 'kg' => t('Kilograms'), 'oz' => t('Ounces'), 'g' => t('Grams')),
      'default_value' => variable_get('uc_weight_unit', 'lb'),
      'weight' => 7,
    );
    $fields['length_units'] = array(
      'title' => t('Product: Dimensions unit'),
      'group' => t('Product information'),
      'allowed_values' => array('in' => t('Inches'), 'ft' => t('Feet'), 'cm' => t('Centimeters'), 'mm' => t('Millimeters')),
      'default_value' => variable_get('uc_length_unit', 'in'),
      'weight' => 8,
    );
    $fields['length'] = array(
      'title' => t('Product: Length'),
      'group' => t('Product information'),
      'weight' => 9,
    );
    $fields['width'] = array(
      'title' => t('Product: Width'),
      'group' => t('Product information'),
      'weight' => 10,
    );
    $fields['height'] = array(
      'title' => t('Product: Height'),
      'group' => t('Product information'),
      'weight' => 11,
    );
    $fields['pkg_qty'] = array(
      'title' => t('Product: Package quantity'),
      'group' => t('Product information'),
      'weight' => 12,
    );
    $fields['default_qty'] = array(
      'title' => t('Product: Default cart quantity'),
      'group' => t('Product information'),
      'default_value' => 1,
      'weight' => 13,
    );
    $fields['ordering'] = array(
      'title' => t('Product: List position'),
      'group' => t('Product information'),
      'input_type' => 'weight',
      'delta' => 25,
      'default_value' => 0,
      'weight' => 14,
    );

        
        if (module_exists('uc_attribute')) {
          //add attribute fields
          //get all attribute ids
          $db_result = db_query("SELECT aid FROM {uc_attributes}");
          $attribute_ids = array();
          while ($aid = db_fetch_object($db_result))
            $attribute_ids[] = $aid->aid;
          //get options for each attribute and add to fields array
          foreach ($attribute_ids as $aid) {
            $attribute = uc_attribute_load($aid);
            foreach (array('enabled', 'required', 'ordering') as $f) {
              $fields['ucatr:'. $attribute->aid. ':'. $f] =   'Product attr.: '.$attribute->name. ': '. $f;
            }
            foreach ($attribute->options as $option) {
              foreach (array('enabled', 'cost', 'price', 'weight', 'ordering') as $f) {
                $fields['ucatr:'. $attribute->aid. ':'. $option->oid. ':'. $f] =   'Product attr.: '.$attribute->name. ': '. $option->name. ': '. $f;
              }
            }
          }
        }
    return $fields;
  }
}

/**
 * Implementation of hook_node_import_prepare().
 */
function uc_product_node_import_prepare(&$node, $preview = FALSE) {
  $errors = array();
  if (_uc_product_node_import_is_product($node->type)) {
    $currency_error = t(' is not valid. It must only contain digits, an optional decimal marker (%decimal), an optional currency symbol (%currency) and optional thousands markers (%thousand).', array('%decimal' => variable_get('uc_currency_dec', '.'), '%currency' => variable_get('uc_currency_sign', '$'), '%thousand' => variable_get('uc_currency_thou', ',')));
    
    //NAME and SKU
    
    if (!isset($node->title) || $node->title == '') {
      $errors[] = t('Product name is required.');
    }
    
    if (!isset($node->model) || $node->model == '') {
      $errors[] = t('Product SKU is required.');
    }
    
    //COST / SELL / PRICE
    
    if (isset($node->cost)) {
      $cost = _uc_product_normalize_price($node->cost);
      if ($cost === FALSE) {
        $errors[] = t('Cost price \'%value\'', array('%value' => check_plain($node->cost))). $currency_error;
      }
      else {
        $node->cost = $cost;
      }
    }
    
    if (!isset($node->sell_price) || $node->sell_price == '') {
      $errors[] = t('Sell price is required');
    } else {
      $sell_price = _uc_product_normalize_price($node->sell_price);
      if ($sell_price === FALSE) {
        $errors[] = t('Sell price \'%value\'', array('%value' => check_plain($node->sell_price))). $currency_error;
      }
      else {
        $node->sell_price = $sell_price;
      }
    }
    
    if (isset($node->list_price)) {
      $list_price = _uc_product_normalize_price($node->list_price);
      if ($list_price === FALSE) {
        $errors[] = t('List price \'%value\'', array('%value' => check_plain($node->list_price))). $currency_error;
      }
      else {
        $node->list_price = $list_price;
      }
    }
    
    //WEIGHT and DIMENSIONS
    
    foreach (array('weight' => 'Weight', 'length' => 'Length', 'width' => 'Width', 'height' => 'Height') as $field => $label) {
      if (isset($node->$field)) {
        if ($node->$field == '')
          $node->$field = 0;
        else if (!is_numeric($node->$field))
          $errors[] = t('!label \'%value\' is not valid. It must be a number.', array('%value' => check_plain($node->$field), '!label' => t($label)));
        else if ($node->length < 0)
          $errors[] = t('!label \'%value\' is not valid. It must be greater than or equal to 0.', array('%value' => check_plain($node->$field), '!label' => t($label)));
      }
    }
    
    if (isset($node->weight_units)) {
      $node->weight_units = strtolower($node->weight_units);
      if (!is_valid_weight_unit($node->weight_units))
      $errors[] = t('Weight unit \'%value\' is not valid. It must be one of %units.', array('%value' => check_plain($node->weight_units), '%units' => join(valid_weight_units(), ', ')));
    }
    
    if (isset($node->length_units)) {
      $node->length_units = strtolower($node->length_units);
      if (!is_valid_dimension_unit($node->length_units))
      $errors[] = t('Dimensions unit \'%value\' is not valid. It must be one of %units.', array('%value' => check_plain($node->length_units), '%units' => join(valid_dimension_units(), ', ')));
    }
    
    //PACKAGE and DEFAULT QUANTITIES
    
    foreach (array('pkg_qty' => 'Package quantity', 'default_qty' => 'Default quantity') as $field => $label) {
      if (!isset($node->$field) || $node->$field == '')
        $node->$field = 1;
      else if (!is_intval($node->$field))
        $errors[] = t('!label \'%value\' is not valid. It must be an integer.', array('%value' => check_plain($node->$field), '!label' => t($label)));
      else if ($node->$field < 0)
        $errors[] = t('!label \'%value\' is not valid. It must be greater than or equal to 0.', array('%value' => check_plain($node->$field), '!label' => t($label)));
    }
    
    //ORDERING
    
    if (!isset($node->ordering) || $node->ordering == '')
      $node->ordering = 0;
    else if (!is_intval($node->ordering))
      $errors[] = t('List position \'%value\' is not valid. It must be an integer (either positive or negative).', array('%value' => check_plain($node->ordering)));
    //don't do range check here because nothing will break if it's greater than the range allowed by the product editing form, and it allows more flexibility
    
    //SHIPPABLE
    
    if (!is_bool_value($node->shippable))
      $errors[] = t('Shippable value \'%value\' is not valid. It must be one of %bools.', array('%value' => check_plain($node->shippable), '%bools' => join(bool_values(), ', ')));
    else
      $node->shippable = is_true_value($node->shippable);
    
    //ATTRIBUTES
    
    if (module_exists('uc_attribute')) {
      foreach ($node as $key => $value) {
        if (stripos ($key, 'ucatr') === 0) {
          $attr = explode(':', $key);
          if (count($attr) == 3) { //attribute values
            switch ($attr[2]) {
              case 'enabled':
                if (!is_bool_value($value))
                  $errors[] = t('Attribute enabled value \'%value\' is not valid. It must be one of %bools.', array('%value' => check_plain($value), '%bools' => join(bool_values(), ', ')));
                else
                  $node->$key = is_true_value($value);
                break;
              case 'required':
                if (!is_bool_value($value))
                  $errors[] = t('Attribute required value \'%value\' is not valid. It must be one of %bools.', array('%value' => check_plain($value), '%bools' => join(bool_values(), ', ')));
                else
                  $node->$key = is_true_value($value);
                break;
              case 'ordering':
                if (!is_intval($value))
                  $errors[] = t('Attribute ordering value \'%value\' is not valid. It must be an integer.', array('%value' => check_plain($value)));
                else if ($value < -10 || $value > 10)
                  $errors[] = t('Attribute ordering value \'%value\' is not valid. It must be in the range -10 to 10.', array('%value' => check_plain($value)));
                break;
            }
          } else { //attribute option values
            switch ($attr[3]) {
              case 'enabled':
                if (!is_bool_value($value))
                  $errors[] = t('Attribute option enabled value \'%value\' is not valid. It must be one of %bools.', array('%value' => check_plain($value), '%bools' => join(bool_values(), ', ')));
                else
                  $node->$key = is_true_value($value);
                break;
              
              case 'cost':
                $cost = _uc_product_normalize_price($value);
                if ($cost === FALSE)
                  $errors[] = t('Attribute option cost \'%value\'', array('%value' => check_plain($value))). $currency_error;
                else
                  $node->$key = $cost;
                break;
              
              case 'price':
                $price = _uc_product_normalize_price($value);
                if ($price === FALSE)
                  $errors[] = t('Attribute option price \'%value\'', array('%value' => check_plain($value))). $currency_error;
                else
                  $node->$key = $price;
                break;
              
              case 'weight':
                if (!is_numeric($value))
                  $errors[] = t('Attribute option weight \'%value\' is not valid. It must be a number.', array('%value' => check_plain($value)));
                else if ($value < 0)
                  $errors[] = t('Attribute option weight \'%value\' is not valid. It must be greater than or equal to 0.', array('%value' => check_plain($value)));
                break;
              
              case 'ordering':
                if (!is_intval($value))
                  $errors[] = t('Attribute option ordering value \'%value\' is not valid. It must be an integer.', array('%value' => check_plain($value)));
                else if ($value < -10 || $value > 10)
                  $errors[] = t('Attribute option ordering value \'%value\' is not valid. It must be in the range -10 to 10.', array('%value' => check_plain($value)));
                break;
            } //switch ($attr[3])
          } //if (count($attr) == 3) else
        }
      }
    }
  }
  return $errors;
}


/**
 * Implementation of hook_node_import_postprocess()
 */
function uc_product_node_import_postprocess(&$node, $preview, $error) {
  if (_uc_product_node_import_is_product($node->type) && !$preview && !$error) {
    if (module_exists('uc_attribute')) {
      //Add attribute data to database
      $attribute_enabled = array(); //$attributes[aid][field]
      $attribute_options = array(); //$attribute_options[aid][oid][field]
      foreach ($node as $key => $value) {
        if (stripos ($key, 'ucatr') === 0) {
          $attr = explode(':', $key);
          if (count($attr) == 3) { //attribute value
            $attributes[$attr[1]][$attr[2]] = $value;
          } else { //attribute option value
            $attribute_options[$attr[1]][$attr[2]][$attr[3]] = $value;
          }
        }
      }
      
      $clear_adjustments = false;
      foreach ($attribute_options as $aid => $options) {
        if (isset($attributes[$aid]['enabled']) && $attributes[$aid]['enabled']) {
          //get default values for attribute
          $attr_default = db_fetch_object(db_query("SELECT ordering, required FROM {uc_attributes} WHERE aid = %d", $aid));
          //update ordering and required fields for product
          if (isset($attributes[$aid]['ordering']))
            $attr_default->ordering = $attributes[$aid]['ordering'];
          if (isset($attributes[$aid]['required'])) 
            $attr_default->required = $attributes[$aid]['required'] ? 1 : 0;
          
          //add attribute to product if necessary
          if (db_num_rows(db_query("SELECT aid FROM {uc_product_attributes} WHERE nid = %d AND aid = %d", $node->nid, $aid)) == 0) {
            db_query("INSERT INTO {uc_product_attributes} (nid, aid, ordering, default_option, required, display) SELECT %d, aid, %d, 0, %d, display FROM {uc_attributes} WHERE aid = %d", $node->nid, $attr_default->ordering, $attr_default->required, $aid);
            //if an attribute was added we must reset the sku attribute adjustments data
            $clear_adjustments = true;
          } else { //update product attribute data
            db_query("UPDATE {uc_product_attributes} SET ordering = %d, required = %d WHERE nid = %d AND aid = %d", $attr_default->ordering, $attr_default->required, $node->nid, $aid);
          }
          
          //set options data
          foreach ($options as $oid => $fields) {
            if (isset($fields['enabled'])) {
              //remove all existing option data
              db_query("DELETE FROM {uc_product_options} WHERE nid = %d AND oid = %d", $node->nid, $oid);
              if ($fields['enabled']) {
                db_query("INSERT INTO {uc_product_options} (nid, oid, cost, price, weight, ordering) VALUES (%d, %d, %f, %f, %f, %d)",
                        $node->nid, $oid, $fields['cost'], $fields['price'], $fields['weight'], $fields['ordering']);
              } else {
                $match = 'i:'. $aid .';s:'. strlen($oid) .':"'. $oid .'";';
                db_query("DELETE FROM {uc_product_adjustments} WHERE nid = %d AND combination LIKE '%%%s%%'", $node->nid, $match);
              }
            }
          }
        } else { //if ($attribute_enabled[$aid])
          //remove attribute from product
          db_query("DELETE FROM {uc_product_attributes} WHERE nid = %d AND aid = %d", $node->nid, $aid);
          $clear_adjustments = true;
        }
      }
      
      if ($clear_adjustments)
        db_query("DELETE FROM {uc_product_adjustments} WHERE nid = %d", $node->nid);
    }
  }
}


/**
 * Check whether the node_import $type provided to the hooks is an ubercart product.
 */
function _uc_product_node_import_is_product($type) {
	/*if (in_array($type, module_invoke_all('product_types'))) {
		return TRUE;
	}
  return FALSE;*/
  return TRUE;
}


/**
 * Make a human formatted price (eg $123,456.78) to a plain decimal (eg 123456.78).
 */
function _uc_product_normalize_price($price) {
  $price = trim($price);
  $price = str_replace(variable_get('uc_currency_thou', ','), '', $price);
  $price = str_replace(variable_get('uc_currency_dec', '.'), '.', $price);
  $price = str_replace(variable_get('uc_currency_sign', '$'), '', $price);
  
  if (empty($price) || is_numeric($price) || preg_match('/^\d*(\.\d*)?$/', $price))
    return $price;
  return FALSE;
}


function is_intval($value) {
  return preg_match('/^[+-]?[0-9]+$/', $value) === 1;
}


function is_bool_value($val) {
  return in_array(strtolower($val), bool_values());
}
function is_true_value($val) {
  return in_array(strtolower($val), true_values());
}
function is_false_value($val) {
  return in_array(strtolower($val), false_values());
}
function bool_values() {
  return array_merge(true_values(), false_values());
}
function true_values() {
  return array('1', 'y', t('yes'), 't', t('true'));
}
function false_values() {
  return array('0', 'n', t('no'), 'f', t('false'));
}

function is_valid_weight_unit($val) {
  return in_array($val, valid_weight_units());
}
function valid_weight_units() {
  return array('lb','oz','kg','g');
}

function is_valid_dimension_unit($val) {
  return in_array($val, valid_dimension_units());
}
function valid_dimension_units() {
  return array('in','ft','cm','mm');
}
zigen’s picture

Subscribing

MaierWerx’s picture

Title: node_import & ubercart 2 » node_import & ubercart 2 (Revisited)
Category: bug » support
Status: Needs work » Active

I've been trying to get node_import to work with Ubercart 2 for some time now, and I can't seem to come up with the right combination of files/fixes/patches/versions. I will appreciate any assistance anyone can provide. I've read through all the posts, tried the various fixes/patches/versions etc... alas, I still cannot import Ubercart products.

I am using all the current versions available:

Drupal 6.14
Ubercart 6.x-2.0-rc7
Node import 6.x-1.x-dev

Currenty, I can run through the entire process and everything works great right up to the Preview (Step 7)... But then I hit "Next", and it just brings me back to the start page; nothing happens; it does not import or give me any error messages. I did notice that the "Next" button at the bottom of the page (on Step 7 (preview)) is dead (it doesn't do anything when clicked).

Can anyone provide any insight? Which versions/patches should I be using? I really appreciate everyone's hard work, and would be very grateful if we could get something working.

Thanks!

zeezhao’s picture

MaierWerx - have you made this change: http://drupal.org/node/569596

MaierWerx’s picture

Title: node_import & ubercart 2 (Revisited) » node_import & ubercart 2

Zeezhao - Thanks for the response. I have made that change, which gets me past the white screen... but once I hit "Next" on Step 7 (Preview Page) I get sent back to the start page. I see that #35 (Parul) has this same problem, but I don't see it addressed anywere. I had this problem once before and got past it only to have other things break. I wish I knew PHP better... I'd really like to get this working...

holsworth’s picture

subscribing.
I get an error message "SKU field is required." but there is no map for the sku field.

"I've been trying to get node_import to work with Ubercart 2 for some time now, and I can't seem to come up with the right combination of files/fixes/patches/versions. I will appreciate any assistance anyone can provide. I've read through all the posts, tried the various fixes/patches/versions etc... alas, I still cannot import Ubercart products."

same here.

bearstar’s picture

Subscribing

MaierWerx’s picture

FYI -

For anyone having a problem similar to my own, I figured out that node_import doesn't like IE for some reason... I tried using Firefox and everything works fine. Just thought I'd pass that along...

pcorbett’s picture

I have not attempted to actually import anything, but I did receive this error when trying to use this module to import other content types:

Fatal error: Call to undefined function uc_product_node_is_product() in /var/www/gocsi.redfinsolutions.net/sites/all/modules/node_import/supported/ubercart/uc_product.inc on line 15

I adjusted this function call per directions provided on the ubercart support site http://www.ubercart.org/forum/bug_reports/12843/csv_import_step_3. Basically, just delete the word "node" from the function call, so:

function uc_product_is_product()

This allows node_import to get past screen/step 3.

Alun’s picture

I had the same problem people have been mentioning, with the node_import skipping straight from step 3 back to step one with no mention of any problem (post 35)

Turns out I was being a complete plonker and trying to import an XML file instead of a CSV file! So if you are having this problem, check that your CSV file is correctly formatted. Though I don't think that many people will make the same mistake as me!

I also implemented jorks fix (post 36) though, my code was slightly different. Instead of
$fieldvalues = strlen($value) > 0 ? $fieldvalues = array(array_pop(array_map('trim', explode($hseparator, $value)))) : $fieldvalues = array($value);
I ended up with
$fieldvalues = strlen($value) > 0 ? $fieldvalues = array(array_pop(array_map('trim', explode($hseparator, $value)))) : $fieldvalues = array($value);

Finally, to sort out the stock value in the import, I used the following node-import fix
http://www.ubercart.org/contrib/11013

Which will allow me to add stock levels in the import too.
I had to alter two lines of the code in this file however, uc_stock.inc calls the depreciated funtion uc_product_node_is_product() twice so just find replace to uc_product_is_product(). You will find the lines you need to change on line 34 and line 101.
edit: Also on line 69.

I am currently importing my products - accidentally imported a whole file instead of a sample, but as it turns out, its currently on record 16485 out of about 40000 and its not been a problem so far!!

MadOverlord’s picture

I too cannot import ubercart stuff. I've added a bunch of fields to my product content type (which is called "product", not "uc_product", if that makes any difference), and I can assign the field items to any of them, but no ubercart fields appear, and then later I'm told the required SKU field wasn't configured.

I have 500 products to dump in, so... (grin)

rhl6856’s picture

suscribing, is there any work arounds available for the following setup:

Drupal 6.14
Ubercart 6.x-2.0
Node import 6.x-1.0-rc4

I vitally need to import products.

rhl6856’s picture

suscribing, is there any work arounds available for the following setup:

Drupal 6.14
Ubercart 6.x-2.0
Node import 6.x-1.0-rc4

I vitally need to import products.

I also have the same error trying to import a CSV file.

rhl6856’s picture

Version: 6.x-1.x-dev » 6.x-1.0-rc4

suscribing, is there any work arounds available for the following setup:

Drupal 6.14
Ubercart 6.x-2.0
Node import 6.x-1.0-rc4

I vitally need to import products.

I also have the same error trying to import a CSV file.

(sorry about the triple post, now I can't figure out how to delete!)

hassansr’s picture

can some one please provide step by step instructions as how to importing products into dp 6 uc 2 is accomplished. I have set up about 10 items manually and have 100 to go.

if the input file is a csv file or a xml file do we figure out what the header fields are and the layout?
included in the csv file is the product image name

what do I do? the export function does not work so I can't see the layout

Zalatar’s picture

FileSize
706 bytes

Attached is a file that I have uploaded. Try it the way it is and then look at the page it creates. I struggled with it for a long time also. Remove the ".txt" at the end of the file name.
You will have to ensure you have an image in your directory or remove the file name in the "Image" field.

Hope this helps,
Z

Updated: If you have changed your node-product.tpl.php, located in your themes folder, you will need to change it back to the original. Not sure why, but that is what I had to do.
Also, if you are using uc_discounts_alt module, you will need to turn it off during the import. Again, not sure why but that is what I had to do.

zeezhao’s picture

#Zalatar - I was able to import your file successfully. I omitted the image column since I do not have you image. Also in "step 5 of 8" I blanked out the separators....

In any case, for the benefit of everyone pending a new release of node_import, attached is a fully patched node_import for ubercart that works in D6 and UC2... Patches were obtained from the node_import forum. It contains a few patches like the update patch (hardwired to use model number from uc_products), etc. The only patch not applied is the stock/attributes patch as it had a conflict with the update one I am using.

Zalatar’s picture

Glad to hear it is working.
Z

razorback’s picture

Hi all -

I need to import products into my undercart and I ran across this thread. So I downloaded the node_import-patched-by-zeezhao.tgz attached in the previous post and i am unable to extract it. Any thoughts? Thanks!!

razorback’s picture

ok, i went and downloaded the latest dev version and have everything setup. I attempted to run the test file that is referenced in the advanced help (bird-houses) and it craps out on step 7 with this:

warning: Parameter 2 to drupal_retrieve_form() expected to be a reference, value given in C:\xampp\htdocs\drupal\modules\node_import\node_import.inc on line 1842.

Any help would be greatly appreciated!! I need this working asap PLEASE! What am i doing wrong? I'm new to drupal..... but learning a lot!

THANKS!!

Alun’s picture

Razorback,
I did a quick search for you, and this issue seems like the same problem
http://drupal.org/node/635788
Give that a go. What version of PHP are you running? I'm not an expert, but the problem on that issue page looks like a PHP 4 error. PHP 5 doesn't do passing by reference, so changing that code would have no effect.

razorback’s picture

Alzum,

Thanks dude!!!! That did it! I really appreciate the help. I did a search for the issue but apparently overlooked that obvious fix. Rock on! :-)

jeremylichtman’s picture

We recently hacked together a PHP script to do a database to database conversion from an old custom-built shopping cart into Ubercart.

I did a short tutorial on our blog, including a downloadable copy of our script here: http://lichtman.ca/learning/moving-data-to-drupal-ubercart

The tutorial covers the list of database tables that may be effected in different scenarios (i.e. custom fields for a product, product images etc).

Hope somebody finds this useful.

jbova’s picture

I have installed this patched version of node_import. What needs to be done while creating a new import to use the update method?

I thought that if I chose no field for "The selected field will be used to find existing objects to update", it would default to the model, which is the SKU. This doesn't appear to be the case as I am getting duplicates instead of updates.

Thank you.

Alun’s picture

jbova, you may be interested to read the following thread - I have uploaded my custom module that uses the SKU to match product and update them.
http://drupal.org/node/422282

jbova’s picture

Alun,
Thanks. I'll give that a try. I mistakenly thought that was included in the patch above by zeezhao.

HongPong’s picture

subscribing - nifty stuff

fender-dupe’s picture

so you are saying this works, because I am just trying to import large number of products

can you import meta desc and meta keywords too?

Militopedia’s picture

Hello,

I just tried node-import for the first time for the creation of ubercart products and it worked just perfectly. However, one very important feature appears to be missing:

  • There is not support for ubercart module uc_option_images (importing different images for different attributes).
  • I think I am not the only one who needs importing different images for different product options.

    Is somebody working on integrating option_images into node_import at the moment (I would support its development with a donation; unfortunately I can't help with any professional programming skills other than basic php, html skills)?

    Is there another possibility to upload and assign option images for products that were imported with node_import?

    Thanks!
    Roger

    fender-dupe’s picture

    Is there a way you can export the existing product pages so you can see how the excel is structured?

    How you name the excel columns? that is my question. It would be much easier to see the excel of current products you have on the site.

    I also have video cck embed field and image cck field, can I import those too?

    Can somebody send me an excel sample of few products so I can see how this baby works?

    thank you

    Alun’s picture

    fender,

    It does not matter what the columns are called when you import - you select them during the import steps, so as long as you know what they are called, node_import doesn't care. It can import CSV files without any field headings. Your image imports might well work, but I doubt the video field will work.

    I don't have any files to hand to help you, but all you need is one product per line in your excel file.

    fender-dupe’s picture

    good, this is awesome

    thank you so much, i thought you have to name the columns with specific names or the import won't work.

    cjdavis’s picture

    A couple of notes:

    - You can name the columns anything you like in any order, but if they each have the exact same name as a field in the content type, node_import will automatically match them up by default. That can save a lot of time if you have many fields.

    - You can set up a csv export of your products (or any other content type) using the views bonus pack - http://drupal.org/project/views_bonus - that too can save you some time figuring out just what is expected.

    fender-dupe’s picture

    Ok, I have finished my first import.

    not happy

    Here are the 2 errors I got.

    * warning: mb_strlen() expects parameter 1 to be string, array given in /home3/altermed/public_html/thaistore/includes/unicode.inc on line 404.
    * warning: mb_strlen() expects parameter 1 to be string, array given in /home3/altermed/public_html/thaistore/includes/unicode.inc on line 404.

    Here are my fields.
    Title Description Catalog Weight Weight unit Length Width Height Dimensions unit SKU image image2 list price cost sell price

    The problem is that the catalog category was not imported, and also the length, width and height were not imported instead I got this in the dimension field

    Dimensions: 0 in × 0 in × 0 in

    I out numbers in each field but get 0

    Can somebody help clarify?

    Alun’s picture

    fender, what version of node_import are you using? rc4 or the latest dev snapshot?
    If you are using rc4, try thew dev snapshot. It is fairly stable and fixes a lot of issues.
    Also try searching for your error message, i found a few threads after searching related to this, you might find the issue has been solved..
    http://drupal.org/node/383926
    http://www.ubercart.org/issue/11196/attributes

    fender-dupe’s picture

    Yes I updated the version to latest dev, the category is fixed but the dimensions still show

    Dimensions: 0 in × 0 in × 0 in

    I can not import till this issue is fixed, everything else works superbly

    Any idea

    Alun’s picture

    here you go, there is a patch on this thread
    http://drupal.org/node/688426

    fender-dupe’s picture

    I tried to patch it from this tut

    http://www.indiawebsearch.com/content/how-to-apply-a-patch-to-a-drupal-m...
    Could not do it, I am attaching the screenshot

    What is the easiest way to patch it, can i find an really easy tut for newbies?

    Or can somebody send me the patched zip to my email fenderguitar[at]gmail.com

    thank you so much

    fender-dupe’s picture

    FileSize
    90.27 KB
    Alun’s picture

    I don't know why it didn't work, I usually just do patches manually. remove the lines where the file indicates - and add the lines indicated by a +.
    You can do them automatically if you get to grips with Eclipse, but its a small patch, just do it manually. I would do it, but I'm not around my main computer at the moment, sorry.

    fender-dupe’s picture

    ok I patch it manually, worked like a charm. thank you people. Drupal rocks!!!!

    babbage’s picture

    @Alun: Wow. You should really look at patching automatically. Life is waay easier when you get the patch -p0 < patchname.patch figured out...

    Alun’s picture

    @dbabbage: I know its the simplest of things to do, but I can be so lazy, the time it takes to do it manually is quicker than learning to do it automatically, and I only have to do it occasionally, so I have never bothered!! That said, I have recently started using Eclipse, and it does have a 'apply patch' feature when I right click on a file, so I might use that next time.

    babbage’s picture

    @Alun. LOL. The entire tutorial is in my comment above... Applies all fragments of the patch across multiple files, when run from the root directory of the module. But each to their own... whatever workflow works is just fine by me. :)

    Phoenixxx’s picture

    I am getting the following error:

    warning: mb_strlen() expects parameter 1 to be string, array given in /includes/unicode.inc on line 404

    Fender, it looks like you fixed your category problem on #102. May I ask what you did to solve that particular error? I am trying to import the categories based on the catalog, same as you, I think, for instance: Clothing >> Mens but am having no luck, and can't find an answer anywhere else.

    Tags are off, but when I turn them on, everything imports fine, but the term imports as a singular term - 'clothing >> mens' as opposed to being two separate terms in a heirarchy, for instance, 'clothing' >> 'mens'. If I'm not mistaken, it should be the latter, correct?

    I am currently using node import 6.x-1.x-dev, ubercart 6.x-2.x-dev, and Drupal 6.15

    Thanks!

    Alun’s picture

    Phoenixxx: have you seen this thread: #434572: Add support for content_taxonomy
    It seems to be on the topic you are talking about. There is a recent patch at the bottom of it.

    zeezhao’s picture

    It may be better if someone posts the "latest fully patched & complete" node_import , just like I did here:

    http://drupal.org/node/349408#comment-2260858

    That way, its easier for anyone who needs.

    Fyi - I also noticed that the dev version was updated on 2010-Feb-06 - see: http://drupal.org/project/node_import

    So not sure what patches have now made it in...

    fender-dupe’s picture

    I have latest versions of node import, before upgrade I could not imprt categories

    but I dont have 2 level deep categories like you are having, only 1 level

    Phoenixxx’s picture

    Alun and Zeezhao,

    Thanks for the tips! It appears that the import now works after both your leads: #434572: Add support for content_taxonomy and the latest dev version of node import.

    Fender,

    To confirm, I am finding that two-deep hierarchies ARE working, if you ever need to use that. The only caveat I found here is that all the terms need to be created in advance in order for the import to go through - though this is probably because I am not using free tagging.

    Thanks again guys, you rock!

    fender-dupe’s picture

    Ok good if it is working for you

    I have only the problem in catalog view where my images are missing, and can't fix this.

    Why you can't set up the catalog images (mysite.com/catalog1......) with views or cck, and select which image you want to use from iamge cache presets. I am bumming myself out with this for so long already.

    Militopedia’s picture

    Has anybody tried yet if the new development version supports uc_option_images?

    Summit’s picture

    Subscribing, greetings, Martijn

    prakash123’s picture

    hi everybody,
    I am new to drupal. I want to import data from existing database. I installed the node importer, i am using ubercart. I loaded the csv file, selected type product but i dont find the price, sku fields while mapping the fields. can anyone help me , i searched through but didn't find a solution, facing problem since last 3 days.

    fender-dupe’s picture

    check if you have all the permissions nabled, also all modules installed and have latest versions of plugins, it worked for me, also I think you need to patch it for importing categories

    dom_b’s picture

    is there a patched uc_product.inc that allows you to import features/downloads to products as well? I desperately need one! I can't work out how to add it myself...

    dom_b’s picture

    Is there no way of importing downloads using node_import? this would be incredibly useful...

    dreadfulcode’s picture

    I just got my first

    Call to undefined function uc_product_node_is_product() ....blah/blah

    today while attempting to import new products into Ubercart.

    Are there any nice cut/paste solutions out there? Any solutions?

    dreadfulcode’s picture

    aha! Found it!

    Change the function uc_product_node_is_product TO uc_product_is_product

    in line 15 of

    uc_product.inc

    which is found in

    \sites\all\modules\node_import\supported\ubercart

    *sigh*

    dreadfulcode’s picture

    So now, a few screens later, I get

    warning: Cannot use a scalar value as an array....

    Everything is mapped out, but it's not converting into a node.

    I am not trying to import pics or taxo terms, just sku #, title, description, cost, and sell price.

    What is this?

    mmsman’s picture

    I am running

    Drupal 6.14
    Ubercart 6.x-2.0
    Node import 6.x-1.0-rc4

    I am trying to do a CSV upload for products, however, when I get to step 7 and preview the items and click next it goes back to step 1 and I lose everything. Someone please tell me what's going on here. Also, since i've uploaded the node import module and date module when I get to pages like node_import/add the page looks funny like its not seeing the CSS correctly, my "layout (background) disappears..... any reason?

    webengr’s picture

    subscribe

    mmsman’s picture

    I know i'm gonna sound stupid, but i'm new here. Subscribe to.......?

    xurizaemon’s picture

    @mmsman: Not a stupid question at all! Drupal.org has long lacked a decent method for people to flag a topic as something they wish to follow without sending issue notifications to all other watchers of that topic. Probably the only "stupid" part is how long (nearly five years?) our community and infrastructure have tolerated the situation. See 3281d's Death to Subscribe Comments and Improving Subscriptions for one attempt to resolve the problem. The latter link there has a number of pointers to other Drupal.org issues which are related.

    Welcome to Drupal.org!

    11Cars’s picture

    subscribe

    11Cars’s picture

    FileSize
    8 KB

    Node_Import Works in May 2010!
    After MANY failed attempts I got node_import to successfully import 6,100 products and connect to the underlying images.

    I experienced every type of error you can find in these forums, including White Screen of Death which is the most frustrating. I searched for alternatives to node_import and could not find one. Since I cant write my own scripts (I don't know php), I needed to make this work.

    If you follow this "In Order" it will work.
    I am running Drupal 6.16, MySQL 5.1.4.1, Php 5.3.1 with php Memory at 128

    My preferred way to duplicate this success would be as follows:
    1. Download the Install Profile "UberDrupal" (6x-1x-Alpha6). Run Status report and update modules.

    2. Add Modules "Date" (enable Date API only), "Advanced Help" & "Node_Import" version 6x-1.0-RC4 from http://drupal.org/project/modules (The more recent node_import Dev files did not work for me)

    3. Enable Modules and run update.php

    4. Download & Install "Node Import Patched by Zeevo" in post #83 of Node 349408. Run update.php. (DO NOT SKIP STEP 2)

    5. Add "&" to "$args" on line 1842 of the node_import.inc file. See http://drupal.org/node/635788 for details on this

    6. Edit your Vocabularies to allow "Tags" and turn off "Required" & "Multi-Select" options

    7. Build your CSV file with Open Office to you can use UTF-8 characters (Excel does not work)

    8. Upload your desired images to /sites/default/files

    9. Run node_import, work the errors out of the first 5 records and go. Note that I leave several required fields out of the csv file and rely on the default option screen. In particular, I use this for the "Published Date" field as I find getting the date format right in Open Office to be tricky.

    I have attached an example CSV file for my product set. Yours will be different. For example the columns "Make / Model Search", "Make", "Model Year" and "Shot" all refer to specific vocabularies in my particular application. That said, when I was beginning this effort, I wanted to view an example and could not find one. (The upload is excel since csv files are not an allowed upload in this forum)

    I hope this helps some newbie save some time. I find this community to be awesome and just want to give back in some small way.

    emanuel.nedelcu’s picture

    did you solve this problem? I just started to use Drupal and I need to do the same thing that you were asking above, import download feature. If you have any idea how I can do this pls let me know... Thx

    dziemecki’s picture

    I want to thank 11Cars for his very detailed instructions. Unfortunately, I got the WSOD (White Screen of Death) on step three of the import wizard, and then decided I needed to handle this a different way. Let me throw this out to anyone getting frustrated by a WSOD - add error display code to the index.php file:

    http://drupal.org/node/158043

    Just this one little modification to your development environment will make tweaking 4th party patches to no-longer-maintained 3rd party modules a comparable joy.

    j0rd’s picture

    @dziemecki: white screen of death errors if they are not caused by code (turn on error_reporting and check your error logs) are usually caused by:

    1. PHP not having enough memory_limit. Turn it up.
    2. PHP not having enough execution time.
    3. PHP not having enough "max post/file size" for uploads.

    It's probably related to #1 though, the other I posted for verbosity. Turn it up to at least 96M. If that doesn't work, temporarily jack it up to like 256M. Also make sure you have enough execution time (at least as long as it'll take for your import to fully run, although I think the Drupal batch processing this uses avoids that).

    @j0rd: Personally what I'm looking for is an attribute and options patch. Along with the code I've found in here, I've also found this thread. http://www.ubercart.org/project/node_import_uc_stock . Checking out all the code now and will post results when done.

    I may end up writing a custom (in code) importer, as it will be more flexible. I'm either going to have to write code to create my CSV or code to create my import. I think the later will be more worth wild...so may go that route.

    jefflane’s picture

    Here is a fix that worked for me:

    1) Open sites/all/modules/node_import/supported/ubercart/uc_product.inc
    2) Change all instances of 'uc_product_node_is_product' to 'uc_product_is_product'
    3) Save the file
    4) Make sure you have php_ini("memory_set", "96M"); in your settings.php (located in sites/default/settings.php). 96M is what I needed, you can adjust as necessary.

    And that worked.

    razorback’s picture

    I have been using node import for several month now for improting large numbers of products with variants (ie shirts that come in multiple color/size combinations). When I upload these products everything look fine - optionsa are added correctly, adjustments tab looks correct and stock tab is correct (contains a "parent Sku" p101 - active unchecked and all related children skus - active checked and distincted item nubers "101,102,103,104") but when our customers checkout online the invoice is receiving the parent sku no matter which child sku is selected. I beleive this is caused by node_import because I can manually create a product with same configurations and everything works correct. The child sku is passed to the invoice screen and not the parent.

    I figured out a "workaround" for now.... it is almost as strange as the issue. After the product is created I can go into the adjustments tab and click save (no other changes) and then the correct item numbers are passed the invoice at checkout.

    Has anyone seen this before?

    razorback’s picture

    Anyone have any thoughts on my question at #136? This may not be the right place for this question but this is the thread where I got the fixes and things I needed to make the tool work so I thought this was the best place to start. If I need to enter this somewhere else just let me know. Thanks!

    j0rd’s picture

    I've extended node_import or more specifically cpILL's node_import ubercart extensions to add support for "Ubercart File Downloads".

    http://www.ubercart.org/project/node_import_uc_stock#comment-55048

    I've extended node_import_supported_v5.zip to add support for importing "Ubercart File Downloads". The only modification between my version and v5 is that I've added this patch to resolve an issue with node_import and PHP 5.3 http://drupal.org/node/763036.

    Additionally I would recommend this patch for uc_product ( http://drupal.org/node/809318 ):
    http://drupal.org/files/issues/ubercart_uc_product_feature_save-6.x-2.2-... as with out it, you will have much grief with duplicates when editing your File Downloads.

    I've also included the additional doxygen generated API docs, so that hopefully others will be able to get a handle on the API and contribute improvements.

    It would be best if we could get these ubercart extensions added into the core node_import, so that others will find and use it. I think in order for that to happen though, cpILL's code will need to properly provide "$values['nid']" in postprocess functions. Right now that'll mess up any other contrib modules which depend on that functionality.

    --
    Ubercart module development

    ar-jan’s picture

    I got the white screen of death when hitting 'Next' on step 3 (Set file options). I wanted to import to another product class than the default 'Product', in to another content type that is. I didn't find this documented yet, so here it is:
    - Copy /sites/all/modules/node_import/supported/ubercart/uc_product.inc to uc_mycontenttype.inc
    - Like in #135, remove the 'node_' part from 'uc_product_node_is_product' in uc_mycontenttype.inc
    - Also change 'uc_product' to 'uc_mycontenttype' so it looks like 'uc_mycontenttype_is_product'

    Now import works fine for other content types / product classes!

    I had Excel installed, so I exported to CSV and then edited the export with Notepad++ to convert to 'UTF-8 without BOM'. Since there are no double quote text delimiters in Excel exports, I replaced all semicolon separators in tabs, which is also supported.

    zkrebs’s picture

    In regards to #137

    I would have phpmyadmin open and look at your database tables ( uc_product_* tables), before and after you make the change. See what has changed, perhaps you could issue a SQL UPDATE command to fix the issue, i.e. activate all your product attributes/options. Sounds like a value stored in the DB is updated when you hit save.

    deggertsen’s picture

    Using the package from #138 I just tried doing a massive import of 938 products. However on the majority of the products I got this error: "An illegal choice has been detected. Please contact the site administrator." I've been looking over the reports for awhile and I can't figure out what could be causing this... Would anybody mind taking a look? I've attached the downloaded rows with extra columns (only the first 200, it was too big without cutting out a bunch of rows) and the Node import debug report. Any help would be great!

    Thanks

    xl_cheese’s picture

    You'll have to peel the banana. Try importing one of the failing products. Then remove the fields one at a time until you get a sucessful import. This should help you target what is exactly causing the problem.

    j0rd’s picture

    **
    * @mainpage Public API of Node import
    *
    * Global variable: $node_import_can_continue
    *
    * Boolean. Some imports may not be able to do more then one row at a
    * time because of all kinds of (static) caching in Drupal. For example
    * if you import a node with taxonomy terms and select to create the
    * non-existing terms on import, taxonomy_get_tree() will not have an
    * up-to-date internal list of terms and so the submission of the form
    * will fail due to "An illegal choice has been detected. Please contact
    * the site administrator.".

    Just did a search on the code and that's what came up.

    I know you run into this problem when your CSV file has values for data that node import isn't expecting. So say you have "Hello" in a field that requires 1 or 0. You will probably get an error like this.

    I would assume this is your problem and not the module (although it could probably provide better error reporting)

    doof2010’s picture

    jim0203’s picture

    subscribing - would anyone like a patch to change line 15 of uc_product.inc as per #124 and #135?

    Anonymous’s picture

    Hi. I was not able to open the node_import-patched-by-zeezhao.tgz file as well. It seems that you found the way to do that Zalatar, in post #84, but I can't really tell by that post. What am I missing?

    SOLVED - well that was strange. Had to save the file first, then decompress instead of decompressing directly at the time of downloading. Never had to do it that way before.

    espirates’s picture

    I got this error "Fatal error: Call to undefined function uc_product_node_is_product() " trying to import 1 node (content type page), now what does ubercart product have to do with page content ? (scratching head)

    Alun’s picture

    @espirates This is an old error which needs updating in the repository, change uc_product_node_is_product() to uc_product_is_product().

    Dimm’s picture

    +1

    Typeface’s picture

    FileSize
    26.23 KB

    Hi

    I have made a products.csv and have imported the products and all went fine the one issue i have is none of the products have gone into there respective categories, i followed the instructions on this website

    http://tomandcrystal.com/creating_products_in_ubercart

    and on that site it says

    "If you are creating products with several categories that are in a hierarchy structure, you must first manually create the taxonomy terms, then adjust your vocabulary setting so that "Tags" are unselected, "Multiple select" is selected, and "Required" is unselected. Then in the "Products" column of you .csv file, use the names of your final end category. For example, if your taxonomy hierarchy looks like "Beverages > Soda > Coca Cola > Ramblin' Root Beer", then the only thing you would type in the column for a product to go under the category of "Ramblin' Root Beer"

    OK so i have followed that info to the letter and basically all my products are in no catagory, everything else imports fine so im wondering if i have somehting slightly out of wack regarding the "Products" column name? Could it have been changed in updates or something simple?

    I have attached a sample of my csv as a txt file, any ideas would be really appreciated, i know i can do each section individually and choose the catalog catagory each time but with 3000 products in 90 catagorys i wanted to at least try getting it working with one csv file.

    cheers

    ar-jan’s picture

    Typeface, try the -dev release, this fixed some problems I had. Also see http://drupal.org/node/437834#comment-1766940 etc.

    itserich’s picture

    I am getting this error even though I am not trying to import a product, just regular nodes:

    Fatal error: Call to undefined function uc_product_node_is_product() in /home/hl90mnvk/public_html/sites/all/modules/node_import/supported/ubercart/uc_product.inc on line 15

    #124 worked. Thanks.

    Sivaji_Ganesh_Jojodae’s picture

    Category: support » bug

    #124 did the trick.

    maaak’s picture

    Category: bug » support
    maaak’s picture

    Title: node_import & ubercart 2 » crash on step 6
    maaak’s picture

    FileSize
    1.09 MB

    Hi all,after much head scratching i have eventually got to step 6.......wahoo he cried only to be faced with that dreaded white screen and the following log error

    mb_strlen() expects parameter 1 to be string, array given in /var/www/vhosts/setsmart.co.za/httpdocs/includes/unicode.inc on line 410.

    i am attaching a .xls copy of my .csv

    any help would be most appreciated,

    yours in confusion\

    i am running d6-9,and u-2

    thankyou for helping!!

    p.s followed #124 and thus got to step 6

    .m

    EvanDonovan’s picture

    Title: crash on step 6 » support for ubercart 2.x in the 6.x version of node_import
    Issue tags: +ubercart integration, +uc_product

    @maaak: Please don't change issue titles to something specific to yourself. It loses track of the overall discussion.

    @all: As someone just coming into this discussion, at a client's request, seems like this issue could do with a summary. What has been committed to the module in regard to Ubercart support, and what remains to be added?

    j0rd, has your work been offered to the maintainer as a patch, or is it simply the custom version of the module offered in #138? Is your work only necessary to support file downloads, or other types of import as well?

    Should a patch be rolled for the fix in #124, or has that already been committed to this module?

    Finally, is there any documentation of the correct process for importing product nodes from a CSV file newer than http://www.ubercart.org/docs/user/11089/import_products_csv_format, which is for 5.x?

    I'll try to answer some of these questions myself, in the hopes of getting this discussion back on track, but anyone who's worked in this area previously is welcome to respond first if they know.

    EvanDonovan’s picture

    Looks like #1026868: uc_product_node_is_product() undefined was committed, and #913406: Ubercart - Integrate Ubercart Fixes describes an issue that is caused by the same thing (change in API to use uc_product_is_product). Should this issue be closed?

    Robrecht Jacques’s picture

    Version: 6.x-1.0-rc4 » 6.x-1.x-dev
    Assigned: Unassigned » Robrecht Jacques
    Status: Active » Needs work

    I'll get over this issue and #913406: Ubercart - Integrate Ubercart Fixes to see what parts of this still needs to be committed.

    The mb_strlen() problems are not specific to Ubercart, but rather to taxonomy.

    EvanDonovan’s picture

    Yea, I didn't think that mb_strlen should be in here. I saw you made that a separate issue.

    EvanDonovan’s picture

    Title: support for ubercart 2.x in the 6.x version of node_import » add additional Ubercart fields to node_import (possible merge with issue #913406?)
    Category: support » task

    I just tested the Ubercart import on the 6.x-1.x-dev, and the import worked perfectly, including a few CCK fields. I did not test the taxonomy issue (which I agree is out of scope for this issue), nor the import of the following Ubercart fields, though:

    • cost
    • weight_units
    • length_units
    • length
    • width
    • height
    • pkg_qty
    • default_qty
    • ordering

    However, I would suspect that these fields would work the same as the ones that I did test.

    I think that comment #138 is the main thing that still could be added to the core node_import package, now that #1026868: uc_product_node_is_product() undefined is resolved.

    I wrote up some documentation on how to do an import of Ubercart products, plus created a sample CSV file. Where do you think would be the best place for that? I suppose the Ubercart docs site would be one, but I don't seem to have access to edit that.

    EvanDonovan’s picture

    @maaak: For your mb_strlen issue, it looks like the place you should be commenting is actually #383926: mb_strlen() errors on taxonomy imports.

    Robrecht Jacques’s picture

    Issue tags: +Documentation

    @EvanDonovan - docs on Ubercart / Node import would be welcomed. If you could write them in Advanced help format (basically HTML), it can be added to Node import and probably the handbook. Could you open a new issue with docs + sample csv attached? We can discuss there what the best place would be.

    EvanDonovan’s picture

    @Robrecht: Are there already docs on how to do a Node Import generally, though? My concern would be that it would duplicate the basic instructions for the most part.

    EvanDonovan’s picture