Now that I've sorted out my problems with PHP thanks to Ryan I've managed to get the XML importing working with images. I am using some additional CCK text fields that are displayed on the product page as part of the description and am using PHP5. Here is my process and some things to consider:
1. Export one of your products so you have some XML to work with. I used XML Tidy (built into TextMate) so I could read the exported XML.
2. I tried to import the exported XML to see if it would work but it gave me a bunch of errors:
- warning: Invalid argument supplied for foreach() in /var/www/html/shop/sites/all/modules/ubercart/uc_importer/uc_importer.module on line 745.
- warning: Invalid argument supplied for foreach() in /var/www/html/shop/sites/all/modules/ubercart/uc_importer/uc_importer.module on line 793.
- warning: Invalid argument supplied for foreach() in /var/www/html/shop/sites/all/modules/ubercart/uc_importer/uc_importer.module on line 922.
- warning: Invalid argument supplied for foreach() in /var/www/html/shop/sites/all/modules/ubercart/uc_importer/uc_importer.module on line 963.
Lyle enlightened me that I needed to add some required fields to the XML to get rid of the 'Invalid argument supplied for foreach()' errors so I used the XML Schema Description to figure out where to add them. I ended up adding:
- /store/manufacturers
- /store/attributes
- /store/classes
- /store/products/product/attributes
- /store/products/product/adjustments
- /store/products/product/adjustments/adjustment
The /store/products/product/adjustment doesn't seem to be in the schema description but I managed to track down where to put it from the uc_importer.module.
There was an error in the exported XML file; there are two occurrences of <description/> in store/categories/category/ which I deleted.
3. Then I needed to sort out images so I created a directory on my server (set to 755, I'm sure less permissions would work but this was the default) and uploaded the image file. I changed the path to reflect the image file's path on the server, for me that was /var/www/html/import/image.jpg. This seems to work sometimes and other times just copies a 0 byte file with the correct name.
4. Delete your product and try to import the XML file you've just modified. Finger's cross it should be working for you without errors.
I hope I haven't missed anything and that this helps someone get their importing from XML working.
Here is the XML file that I've imported so you can compare it to your own:
<?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">
<categories>
<category>
<id>1</id>
<name>Accessories/Misc</name>
</category>
<category>
<id>18</id>
<name>EP82</name>
</category>
</categories>
<manufacturers></manufacturers>
<attributes></attributes>
<classes></classes>
<products>
<product>
<unique_hash>f560ab2ba8c286b1d64f7cdf39bae82b</unique_hash>
<id>1</id>
<type>product</type>
<name>TRD Carbon Emblem</name>
<description>Carbon Emblem E-Type by the Racing Development team from Toyota, TRD. This TRD carbon emblem is composed of real carbon fibre with silver print for the logo and will be a great addition to the interior or exterior of any Toyota vehicle.</description>
<model>TOY-EMB-0001</model>
<list_price>0.00</list_price>
<cost>0.00</cost>
<sell_price>10.00</sell_price>
<weight>1</weight>
<weight_units>Kilograms</weight_units>
<image>
<path>/var/www/html/import/trd_carbon_emblem.jpg</path>
<alt>TRD Carbon Emblem</alt>
<title>TRD Carbon Emblem</title>
</image>
<fields>
<field>
<name>field_application</name>
<delta>
<value>EP82 GT/EP91 Glanza/4efte/4efe</value>
</delta>
</field>
<field>
<name>field_extrainfo</name>
<delta>
<value>N/A</value>
</delta>
</field>
<field>
<name>field_deliveryinfo</name>
<delta>
<value>Free UK Mainland Delivery on all items.</value>
</delta>
</field>
</fields>
<categories>
<category>
<id>18</id>
</category>
<category>
<id>1</id>
</category>
</categories>
<attributes></attributes>
<adjustments>
<adjustment></adjustment>
</adjustments>
</product>
</products>
</store>

