Import/Export

Posts: 53
Joined: 08/08/2007

I'm trying to migrate products from a shop that uses a MS Access db to UC. I first converted the data to MySQL and am now building the XML file for import. Is it right that uc_importer.module currently does import CCK image fields but doesn't export them?

I found a typo on line 212 in uc_importer.module:
$xml .= _uc_importer_export_manufacturers($dataa['manufacturers']);
should be:
$xml .= _uc_importer_export_manufacturers($data['manufacturers']);

Also, the return was commented out at the end of the function, so it didn't write any file:
return file_save_data($xml, file_directory_path() .'/uc_export.xml', FILE_EXISTS_REPLACE);

Glad ubercart.org is back(ed up?...)

Posts: 165
Joined: 08/08/2007
Early adopter... addicted to alphas.Getting busy with the Ubercode.

I'm keen to see a CSV import module happening (or write one myself). I was thnking that perhaps going from

Excel -> CSV -> XML -> Ubercart

would be the way forward since the XML importer already exists. Is there a spec for the XML that Ubcercart likes?

Now that I'm thinking about it perhaps Excel could export to XML and then a general XSLT template could be developed to et this in the UC preferred format?

--

suffering from too much information

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

There is a schema definition available at http://www.ubercart.org/files/store.xsd, so if anything's an approved version, that would be it. It's been changing with the importer module as I figure out the best ways to do things, but it should be fairly stable now.

Guest (not verified)

+1 for CSV -> Store

Posts: 53
Joined: 08/08/2007

I have added some custom fields (year, condition, accessories etc) to my product content type. I don't quite understand if such fields can be populated using the current importer module. Can you give me an example "snippet" that shows how data for such fields would be represented in the XML?

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

So far I've come up with something like the attached file. I didn't put any information about the kind of field because I think it's the user's responsibility to make sure the content fields are set up right on both sites. The <value> tags may be named something different for different fields, especially if they store more than one piece of information per field.

AttachmentSize
cck_fields_export.xml1.15 KB
Posts: 20
Joined: 08/15/2007
Bug Finder

Thanks Lyle. Now how would I import your xml file into Ubercart - just fire up importexportapi in Drupal and point it to the xml file?

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

When you have the uc_importer module enabled, there's a form in admin/store/products/import that you can go to that's specifically designed for Übercart files. My importer is independent of importexportapi mostly because it threw a bunch of errors at me whenever I looked at it's pages. So I started from scratch and made a custom solution.

Edit: Actually, the URL might be different depending on your version. I can't remember when I changed it, but you might need to go to admin/store/import instead. It's a normal menu item, so you should see it in the menu links wherever it is.

Posts: 20
Joined: 08/15/2007
Bug Finder

Ok thanks - that makes sense. Where can I get my hands on the uc_importer module? It doesn't seem to be on this site (at least, a site search comes up blank) and google only has one reference to it - at bazaar.ubercart.org - but it's not in cvs on drupal.org - could you please post it here as an attachment or let me know where I can download it?

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

Ah! Sorry about that. I keep forgetting what's been done since the last release, so I figured since it's in the bazaar repository you had access to it.

Here it is.

AttachmentSize
uc_importer.tar.gz9.6 KB
Posts: 20
Joined: 08/15/2007
Bug Finder

Thanks for the super-fast replies! I don't know how to access the bazaar repository, so some guidelines somewhere would be quite helpful at some point. But for now I'm going to start playing with the module and see if I can start importing products Eye-wink

Posts: 20
Joined: 08/15/2007
Bug Finder

Ok, this looks great. Easy to use too. I've got over 100 products in csv which I'll now format into the correct xml definitions - the only question is the unique_hash key. I see it's a field in the uc_products table - do I need to generate a similar (unique) hash per product in my xml importing - or can I leave it blank? I take it that it's there for some reason to uniquely identify a product?

Posts: 20
Joined: 08/15/2007
Bug Finder

Don't worry - I just found that you generate the hash in the import code.

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

Yeah, the unique hash is preparation for a module that's to be used for multi-site setups. It would allow you to make a change to a product on one site, and then export that product to the other sites automatically. Because the node ids can be different, Übercart generates the unique_hash when the node is first created, allowing the module to find the right product to change.

Posts: 116
Joined: 08/08/2007
Brain Stormer

I'm a little confused. Why the third abstraction from csv -> XML -> uc and not just csv -> uc?

I imagine it's to potentially make future imports of other "types" easier (write to one interface) but it kind of creates just as much work doesn't it (at least for the person that's going to have to import the data and covert each set of data (csv etc) to the uc xml spec == 2 conversions instead of one)?

i'm biased towards csv because that's what i'm going to use to import (Eye-wink) and outside of it, i'm not sure how many different import methods actually are used in practice? If there aren't many other methods, that extra abstraction to xml might be wasted? csv is supported by php so it's a straight shot if someone builds out csv -> uc importer. And i could see people using it a lot and fairly easily. But maybe not

xml is valid i'm sure, i just haven't gone down the path yet so wondering why all the emphasis is being placed on it or what benefits it brings by using it? Maybe your importer magically insulates the coding of the actual cck fields and such that would have to be changed for every individual use of an import script.

if i had a second to breathe, i'd have finished an uc csv import script (not a module) by now but unfortunately i don't. Sad.

imho, a standardized and documented import is THE thing that uc needs right now above all else. Otherwise store conversions can't take place. That means "most" uc implementations are "probably" going to be brand new store implementations or ideas. Or that others have written their own private import scripts to complete their stores.

thanks

Posts: 116
Joined: 08/08/2007
Brain Stormer


I'll now format into the correct xml definitions

How does one take a csv file and format it into *xml* definitions? What *are* the xml definitions? Is there documentation on the uc site or is this info specified in the zip file? I guess i'm wondering what the xml definition actually means.

And can this formatting be done quickly and easily with find and replace in the spreadsheet app or vi or some other editor, or is it mostly a manual op for each record?

thanks

Posts: 20
Joined: 08/15/2007
Bug Finder

The xml field definitions are here: http://www.ubercart.org/files/cck_fields_export.xml

Or you can install the uc_importer.module and do a single product export, then take a look at the generated xml file. The xml is pretty self-explanatory.

I'm going to be writing something today which will convert my csv product file into xml. It'll be a bit of (standalone, for now) php code which will take csv as input (initially by pasting into a textarea), do the formatting stuff and then give xml as output (either in pre tags or in a textarea again). I've defined some extra CCK fields within my product type so my solution won't suit everyone. Step 2 would be to map csv fields to CCK fields dynamically - I guess since this is something a lot of people want right now there'd be a bit of demand for it?

Lyle, shall I go ahead and upload this as a contrib module once it's done? It won't be anywhere near mature - but the version I'll upload should help prepare a csv file for import into the vanilla product definition.

As for your other question, druru, why not import the csv directly into the database? Good question! I haven't looked at the uc_import module much yet, but that's the code that Lyle has written and I'm happy to work within it. If you want to go ahead and write your own csv importer, go for it Smiling Just make sure you generate the hash key in the correct way (line 762 in uc_importer.module)...

Posts: 20
Joined: 08/15/2007
Bug Finder

I'm using the converter at http://www.bytemycode.com/snippets/snippet/448/ to convert my .csv into xml. I'm about 1/2 way through so far - got the php script to read in values from the xml file. Now I'm mapping those values across to the Ubercart product field values - and adding in capacity for CCK fields.

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

druru, I went with XML mostly because I was familiar with it. (I really wanted to use YAML, but PHP doesn't have an easy library for it, and everybody said no one would know what to do with it.) While CSV is technically simpler, I wasn't sure I would be able to represent things like attributes and categories easily because you don't know how many each product is going to have. I'm sure there's a technique that most people know, but I didn't, and I didn't try to find out what it was.

I would say that the two conversion steps is only useful if you already have a way to generate a CSV file of your store. If it has all of the compatible data, I think it would be easier to make XML from that than trudging through the database again.

I agree that the importer needs to be documented. I think it's as abstract as it can get because I'm using functions like node_save() and drupal_execute() whenever the data is retrieved from the XML file. I don't think I (personally) will write any other import methods, but I think anyone who wants to can emulate what's already been done.

Posts: 53
Joined: 08/08/2007

Thanks, Lyle. I've added the 'fields' element to my XML, updated uc_importer.module to the latest revision and import works smoothly to my custom fields. But how about images? Image import is commented out around line 815 in uc_importer_import()...

Posts: 20
Joined: 08/15/2007
Bug Finder

futurist, you're working directly on XML right - you're not generating it from csv? Otherwise I'd love to have some of that code! Eye-wink

Posts: 53
Joined: 08/08/2007

I'm migrating products from an old shop into UC. Like I said in my first post, I go Access -> MySQL -> XML -> UC. I've written up a custom PHP script to generate the XML according to Lyle's example (cck_fields_export.xml). It's similar to the export.php he published with the first release of uc_importer.module (see this archived thread). I'll try documenting my script once I get image import to work Eye-wink

Posts: 20
Joined: 08/15/2007
Bug Finder

Ok thanks - can't find a copy of export.php but I'm guessing that's incorporated right into the uc_importer module now. Reading through that link you just posted it seems that the importer only works with php 5...doh! My testing and production server are both running 4...although I have a spare Mac which I could install 5 on.

Posts: 53
Joined: 08/08/2007

No, export.php generates the XML uc_importer likes from an existing MySQL db. Since the shop you are migrating from can have any structure, this must be custom code. I'm also using my export.php to map old relations to the custom fields in my UC product type.

Posts: 53
Joined: 08/08/2007

Another problem: All imported products are 'orphaned' even though I've assigned a term id to each of them like so:

<product>
  <type>product</type>
  ...
  <categories>
    <category>
      <id>11</id>
    </category>
  </categories>
</product>

The terms were created before the import in admin/content/taxonomy. The tid '11' corresponds to one of those terms. What's wrong? (There is no insert to the term_node table in uc_importer...)

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

The original importer module only works with PHP5 because of Simple XML. Because I found JSimpleXML from Joomla! which works in PHP4, I've rewritten the importer to use it in case anyone's still stuck in PHP4.

Edit: Removed due to errors. See below for an updated module.

Posts: 53
Joined: 08/08/2007

Hmm, any idea concerning my image import and category issues? Thank you.

Nevmoor (not verified)

I have just found this great set of modules and it looks like it will do everything I need BUT I am a n00b at drupal and know very little programming. I have read this thread and have created a CSV file from Excel of a list of products for a NEW store. I don't quite understand the steps needed to convert to XML>IMPORT to UC. Could you tell me how to use the script mentioned earlier in the thread? I have downloaded the TXT file but how do you execute the script??

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

Spent this afternoon typing this out: http://www.ubercart.org/docs/user/354/importing_data

The part your looking for is "/store/products/product/fields" and right after. Hope it's helpful.

Posts: 20
Joined: 08/15/2007
Bug Finder

Hi Nevmoor - I'm working on a csv -> XML script as we speak. Once your data is in XML it's pretty simple to import it into Ubercart using the instructions earlier on this page. Might be an idea to export some of your products into XML using uc_importer.module and then import them back so that you start to get a feel for how the whole process works. I'll post my script on this page once I'm done Smiling

Posts: 20
Joined: 08/15/2007
Bug Finder

Thanks Lyle, the php4 version of the importer looks good. Just had 2 errors when I ran it - and they were silly fixes:

Line 744 I changed to:

        $fix = $product_data->unique_hash[0]->data();
        watchdog('importer', '<pre>'. print_r($fix, true) .'</pre>');
        if (!isset($fix)) {

Line 853 I changed to:

          $fix = $attribute_data->default_option[0]->data();
          $default_option = isset($fix) ? (string)$attribute_data->default_option[0]->data() : $attribute_data->options->option[0]->id[0]->data();

In both cases this has to do with php4 seemingly unable to process the following code within a larger

$product_data->unique_hash[0]->data()

But now that that's done, I installed the php4 module (by overwriting the other one in the uc_module folder) and it's not picking it up as a menu item in the store backend like it did with the latest version. Am I missing something?

Posts: 20
Joined: 08/15/2007
Bug Finder

This might be because I first used the php5 version and am only now using the php4 version. The link defined in the php4 version is "admin/store/products/export" and if I navigate there (with the module installed) it just takes me to the "admin/store/products" page. Suggestions?

Btw, in terms of progress with the csv -> xml converter (before I head to bed) is good (but slow): I've got it to generate the following code from my csv:

<products>
<product>
<type>product</type>
<name>Aciphex (Pariet)</name>
<manufacturer>Janssen-Ortho</manufacturer>
<cost>$49.10</cost>
<fields>
<field>
<name>field_generic_name</name>
<delta>
<value>Rabeprazole Sodium</value>
</delta>
</field>
<field>
<name>field_strength</name>
<delta>
<value>10mg</value>
</delta>
</field>
<field>
<name>field_type</name>
<delta>
<value>International Brand</value>
</delta>
</field>
<field>
<name>field_sabre_name</name>
<delta>
<value>Pariet 10mg Tabs (Janssen-Cilag)</value>
</delta>
</field>
<field>
<name>field_pack</name>
<delta>
<value>28</value>
</delta>
</field>
</fields>
</product>
</products>

I haven't yet enclosed it within a store tag and the catalog category. I've also got a CCK field which references a category within drupal and I'm not quite sure how to link that across (by term id? Does the importer support categories?)

ps - I'm doing this for a client, so NO I'm not selling pharmaceuticals and YES I'm making sure he isn't sending out ANY emails.

Posts: 53
Joined: 08/08/2007

Your new documentation is a great help. However, I'm still confused concerning image import. The XPath /store/products/product/image appears in the schema definition but not in the documentation. So I dropped the 'image' element from my product and instead tried the following (assuming that image type fields should now appear similarly to text type fields in the XML):

<fields>
  <field>
    <name>field_image_cache</name>
    <delta>
      <value>http://mysite/import/example.jpg</value>
    </delta>
  </field>
  ...text type fields...
</fields>

An image file 'example.jpg' exists in the 'import' dir. But that doesn't work either. Can you please tell us if image import works at all with the module and if yes, give a short example on how the XML should look?

@macgeek: Sometimes I noticed that disabling and then re-enabling a module made it appear in admin.

Posts: 20
Joined: 08/15/2007
Bug Finder

Ah, newbie error. That did the trick, thanks Smiling

Nevmoor (not verified)

This is great! I am slowly 'getting it'. I need to do the importer for PHP4 so I am going to use the above advice for changing the code to get it to work. If I can get this down, I will be able to do 3 or 4 online stores in the next couple of months!! I will definitely keep up with these forums.
BTW does anyone have a suggestion for a PHP editor? I have DW but that doesnt cut it for me.
I am doing all these changes to a subfolder of an active site on shared hosting,which I know is a little dangerous but since it's not really up I hope I don't crash anything!

Posts: 15
Joined: 08/17/2007

OK I am starting to 'get it'. I have been playing around with this a bit. Now I need to make the.module change for the PHP importer so I can try to export an example product. macgeek, whenever you get you script done let me know! I am no programmer at all, but I can manipulate code once I understand a little of how it all works. Keep up the good work everybody!! UC is a great module for drupal

Posts: 4
Joined: 08/08/2007

Thanks, Lyle! Cheers all around! Now, about that YAML... Smiling

Posts: 15
Joined: 08/17/2007

Just found out my client actually had a MS Access database as the original form of their product list! Access has an export to XML function. SO... I wanted to test this out.

I tried to export a product from UC and then re-import it.
all I got in the exported file was this:

<?xml version="1.0"?>
<store xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ubercart.org http://www.ubercart.org/files/store.xsd"></store>

What am I missing? I have taken the Access database and added/shifted the column orders to match the schema you guys linked to. I just want to get the import/export module working as step 1.

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

You have to press the "Select" button to get products in the bottom box before the exporter will pick them up. It's a bit convoluted, but it allows you to get products from more than one category at once. While the exporter works, it does need some polish and documentation still.

Posts: 15
Joined: 08/17/2007

Actually I discovered a few things that were basically theme issues. To bad Drupal doesn't have a lot of folks doing cool themes. It's getting there but for us lazy folks it's difficult. I am going to stick with the default until the store is functional. Then I will reach out for help!!
I just exported my test product and everything lines up. Now I have to get the importer to work. My host has PHP4.3.11!! When I FTP the importer.module ( the renamed importer_php.module) into the importer module folder, I get a Drupal crash and the whole site locks up. I am probably doing something stupid, but it's just my code ignorance. I will try again this evening and let you guys know whats what.
THANKS!

Posts: 15
Joined: 08/17/2007

Getting this error again

Fatal error: Call to undefined function: simplexml_load_string() in /home/content/F/o/r/mysite/html/store/sites/all/modules/uc_importer/uc_importer/uc_importer.module on line 656

I know this has to do with the importer for php4 vs 5 simple xml but I don't know how to solve it.
Are all the code fixes mentioned in the above posts already coded into the latest uc_importer?

I also just got an error from the pathauto module:

warning: preg_match(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 3 in /home/content/F/o/r/mysite/html/store/sites/all/modules/pathauto-5.x-2.0-beta2/pathauto/pathauto.inc on line 72.

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

Ah, I had nearly forgotten the code fixes. Here's the corrected file.

When you get it, you'll need to rename it to uc_importer.module and replace the module file you already have. Then, you should disable and re-enable it to make sure Drupal loads the correct thing. You were getting an error because it was still using the 5-only version.

Also, pathauto seems to be kind of broken. We'll forgive them because it's still in beta, but you might want to stick with previous versions until it gets sorted out.

AttachmentSize
uc_importer_php4.zip8.33 KB
Posts: 53
Joined: 08/08/2007

No more orphaned products after import! I had set up product categories in admin, added some products manually and then tried to import more using uc_importer. But the imported products didn't have any category assigned to them. Here is how it works (thanks, Lyle):

Since you know ahead of time which products go in which category, you should "import" those categories too. Since they'll have the same name in the XML and the database, the importer will recognize the duplicate and decide what to do based on its configuration. Since the default is "do nothing", it will map the to the term id and be able to put the products in the right place when it gets to them. Considering that you already have the products with the right term id, you can give the tags the same number. It's only used as a reference.

(I think this should go in the documentation.)

The only missing thing now is image import...

Posts: 15
Joined: 08/17/2007

Lyle, I just dropped the importer module for PHP 4 in to the uc_importer folder( after renaming it of course) and I got another error:

Parse error: parse error, unexpected '(', expecting ',' or ')' in /home/content/F/o/r/myinfo/html/store/sites/all/modules/uc_importer/uc_importer/uc_importer.module on line 746

Is there anything I should be changing in the code that I don't know about?

BTW what is a good open source app to view/edit code?
Dreamweaver is a pain sometimes when you try to go line by line. It doesnt always show things on the 'right' line number consistently.

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

I bet that's the same kind of error that macgeek caught earlier. Change that line to

<?php
       
if (!isset($product_data->unique_hash)){
?>

and that should take care of it. There's a few more lines that will do the same thing because of the isset(), so either change your copy or get the updated one in the post above.

Boo on Dreamweaver. We use jEdit, and I haven't found another text editor I like better.

Posts: 15
Joined: 08/17/2007

The site I am doing is hosted by godaddy( my clients choice not mine)
I found out that they actually have PHP 5 installed but you need to make the file extension .php5 in order for the script to be run in 5. I think thats stupid, isnt 5 mostly back compatible? Wouldn't it run all .php scripting or is there something I don't know??
SO....Does this mean I only have to change the extensions in the uc_importer module code? I would hope so.
I am going to try that while I wait for your replies. I know you guys are busy working on your own issues so that's thanks for dealing with a n00b!!!.

Posts: 328
Joined: 08/07/2007
Administrator

Nevmoor,

If you're using Linux hosting for GoDaddy, setting the following lines in your .htaccess file will make the server use PHP 5 as the default with files using the .php extension:

AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4

If you're using Windows hosting...well I don't know.

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

You wouldn't want to change any of the module files because they don't have php extensions. Instead you'd change the files that actually run Drupal, like index.php and update.php. I believe those are the only two files that are called directly by the browser. Everything else gets loaded by include(), so they should be run by PHP5 as well.

To avoid any unexpected "File not found" errors, I'd see if you can get godaddy to go in the other direction, and make PHP 4 have the special extension. I think they can do that on a directory by directory basis, so that shouldn't affect anyone else hosted on your server.
It seems Shawn beat me to it. Sticking out tongue

Posts: 34
Joined: 08/16/2007

I've got a nice excel sheet with all the info.
Trying to map it to the store.xsd. Quite a job, maybe Access is easier?

If I ever succeed I'd like to help with an extension to SimpleStock import.
What's the current development status of that?

It would seem logical to expand the XML Schema Description with SimpleStock values?
something like
/store/products/product/simplestock,Container, No unbounded
/store/products/product/simplestock/numberstock, Decimal, No 1
/store/products/product/simplestock/trackproduct, Integer, No 1
/store/products/product/attributes/attribute/options/option/simplestock, Container, No unbounded
/store/products/product/attributes/attribute/options/option/simplestock/numberstock, Decimal, No 1
/store/products/product/attributes/attribute/options/option/simplestock/trackproduct, Integer, No 1

Or are there other stock import ideas?

Posts: 328
Joined: 08/07/2007
Administrator

I win again! Woo hoo!

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

Posts: 15
Joined: 08/17/2007

I found that .htaccess thing last night but I am just about to get into it and change it. I will let you guys know what happens after all the changes. UBERCART RULEZ!

Posts: 15
Joined: 08/17/2007

I am now running PHP 5.1.4 !!!!

I was also seeing if I could get my MS access database straight to XML without doing the MS Access>mySQL step. the XML isn't exact, but with a little manipulation I think it will eventually work.

Posts: 20
Joined: 08/15/2007
Bug Finder

Hi Lyle

I've upgraded to php5 and am using the php5 version of uc_importer (dated August 9th - don't know if you've done updates on it since then?). Using that, if I export a single product and then use the resultant xml file to try to input, it gives me a failure:

    * warning: Invalid argument supplied for foreach() in /Users/roger/Sites/bestbuydrugs.net/website/ubercart/drupal-5.2/sites/all/modules/uc_importer/uc_importer.module on line 676.
    * warning: Invalid argument supplied for foreach() in /Users/roger/Sites/bestbuydrugs.net/website/ubercart/drupal-5.2/sites/all/modules/uc_importer/uc_importer.module on line 697.
    * warning: Invalid argument supplied for foreach() in /Users/roger/Sites/bestbuydrugs.net/website/ubercart/drupal-5.2/sites/all/modules/uc_importer/uc_importer.module on line 738.
    * warning: Invalid argument supplied for foreach() in /Users/roger/Sites/bestbuydrugs.net/website/ubercart/drupal-5.2/sites/all/modules/uc_importer/uc_importer.module on line 844.

These lines have to do with categories (I also have a few custom CCK fields - see my xml posted earlier on this page) - should my import be failing, or am I doing something wrong?

Posts: 15
Joined: 08/17/2007

I got these errors tonight

# warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/content/F/o/r/ForDivinity/html/store/sites/all/modules/uc_importer/uc_importer/uc_importer.module on line 656.
# warning: Invalid argument supplied for foreach() in /home/content/F/o/r/ForDivinity/html/store/sites/all/modules/uc_importer/uc_importer/uc_importer.module on line 658.
# warning: Invalid argument supplied for foreach() in /home/content/F/o/r/ForDivinity/html/store/sites/all/modules/uc_importer/uc_importer/uc_importer.module on line 670.
# warning: Invalid argument supplied for foreach() in /home/content/F/o/r/ForDivinity/html/store/sites/all/modules/uc_importer/uc_importer/uc_importer.module on line 676.
# warning: Invalid argument supplied for foreach() in /home/content/F/o/r/ForDivinity/html/store/sites/all/modules/uc_importer/uc_importer/uc_importer.module on line 697.
# warning: Invalid argument supplied for foreach() in /home/content/F/o/r/ForDivinity/html/store/sites/all/modules/uc_importer/uc_importer/uc_importer.module on line 738.
# warning: Invalid argument supplied for foreach() in /home/content/F/o/r/ForDivinity/html/store/sites/all/modules/uc_importer/uc_importer/uc_importer.module on line 758.

I got back to the original uc_importer for PHP5. I thought I had the schema right but I guess not.

Posts: 15
Joined: 08/17/2007

OK I did some quick work on my XML.
now the importer says it was successful but there are no new products added!!
I suspect that my XML must not be right. I have almost 400 products so I have to get this to work. Actually I probably could have done this by hand after all this time but I want to get this right!

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

bkudria had been having the same kind of problem on Friday, but we couldn't figure out the problem. I was able to take his XML and import it with no problems.

nevmoor, it sounds like you have a different problem, though. Post your XML so I can see if there's anything to change.

Posts: 34
Joined: 08/16/2007

To use SimpleStock, every option should have it's own SKU (model).
But the import has no way to import a "model" to a product-option.
Is that on the todo list already?

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

It wasn't, but I guess it can be. Shouldn't be a problem to get that working.

Posts: 20
Joined: 08/15/2007
Bug Finder

Ok, well that leaves me kinda stuck! I can generate similar xml but can't import it. So I offer up my csv->xml converter script, which gets me to the same point of the uc_importer generated xml after a good product export.

First, export your excel document into csv, with the first row being column headings. Then fire up the csv2xml.php script in your web browser, and make sure you've uploaded your csv file into the same path.

I've also attached the example file I've used as my csv input (just 2 rows - a header row and a product data row) - just remove the .html at the end (comments don't allow a .csv file as an upload option).

It's rough and ugly, but does the job. Let me know if it's useful. Ideally it would be integrated into the uc_importer module. And optimised! Right now it reads the .csv file about 3 times during the course of the export...

AttachmentSize
product-single.csv_.html229 bytes
csv2xml.php_.txt12.52 KB
Posts: 34
Joined: 08/16/2007

If i run the import twice, all the manufacturers,the attributes, the categories are overwritten (that was my option in the configuration), but the products are not.
It looks like the import needs the same "unique_hash" to be overwritten.
That does make sense, but wouldn't it also make sense that the SKU is used as an identifier for a product to be overwritten? Maybe as option in the config?

Posts: 34
Joined: 08/16/2007

aaah,

function uc_product_insert($node) always creates a new unique_hash.
So you cannot use the hash across systems right now.

I think I will get this bazaar thing working. I need the latest code.

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

I've committed a change to the importer (both versions) to handle product model adjustments. Attributes and options can now import and export their ordering and price and weight defaults. I've also fixed some problems in the PHP4 version that might have been causing problems for some of you.

I think there might still be issues with assigning options to products, especially if there are already existing options with the same name. I haven't isolated the problem yet, but it's something to be aware of.

Posts: 53
Joined: 08/08/2007

There is an "undocumented" feature in the importer module: Image import Eye-wink

(Something like) this should be added to the schema description:

/store/products/product/image (Container; No, unbounded; Container for the image data.)
/store/products/product/image/path (String; Yes, 1; Path to the source file.)
/store/products/product/image/title (String; No, 1; Image title.)
/store/products/product/image/alt (String; No, 1; Image alternate text.)

Perhaps the documentation should also remind us that for image import to function, images must be uploaded with FTP to the source directory specified in the path element prior to running the importer.

I'm not sure how it is defined in Drupal (or Image cache?) which image file types are supported and if there is a limitation to the size of the source files. Maybe a reference to these could be made in the documentation too.

Finally, what kind of surprises me is that apparently no addition (path, title, alt) was necessary to the schema.

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

I didn't put the image in the documentation because I thought I would be taking it out. As it happens, I'm leaving it in.

I think each site can have different settings for its Imagefield, so the importer should conform to whatever settings those are in terms of file type and size. There isn't a hard limit on the size of the files, but you should know that the files are transferred from the source directory to drupal_root/files/ubercart_images on your site.

I'll detail all of this in the documentation today.

Posts: 53
Joined: 08/08/2007

Thanks. I wouldn't mind if you took out the image and used field/type, field/name and delta for path, title, alt instead. Or anything you prefer - as long as the importer supports image import.

Posts: 1850
Joined: 08/07/2007
AdministratoreLiTe!

That's what I wanted to do, but it doesn't work so well because image fields are really references to the file rather than the actual image data. Either the images would have to already exist on the new server and in the files table, or there would be a lot of broken links. That doesn't work, so we're back to handling images as a special case.

Posts: 116
Joined: 08/08/2007
Brain Stormer

hate to be a wanker.. but since this is a pretty huge thread and a mighty useful one, does any of the participants in this thread that have actually walked through this process feel like documenting an actual import case with a mock set of data. i know it would save me a lot of time as well as many others in the near future. so it's going to be a total volunteer effort by whoever does it if they decide to.

posters here are using real data in real life backend situations that we in the forum's don't see. lyle understand's the questions they ask because he designed the import module. that leaves me and maybe other's trying to visualize what they're "really" talking about. how to get from A (my data) to Z (imported and mapped correctly in a working uc).

It doesn't have to be a thesis. But a numbered list of steps that maps a sample product record with images would be fantabulous. An occasional "gotcha" or "be careful" note would seal the deal.

thanks for any takers on this one.

Posts: 15
Joined: 08/17/2007

macgeek, lyle.....
I used the CSV to XML script. WORKS GREAT! It does exactly what it should. BUT.....
Even though everything looks good, uc_importer still doesn't actually create the products or at lease UC doesn't seem to see them...
The XML file: oil_list1.xml

Posts: 34
Joined: 08/16/2007

oil_list1.xml is not a proper XML file
All "&" signs should be "&amp;"

good luck