Lost password?    Lost username?    Create an account
OverviewDownloadsForumSupport
CSV Improved

CSV Improved

Import XML

This tutorial will explain how to:

  • Analyze the XML file
  • Setup an import template for the XML file
  • How to import the XML file

Requirements for this tutorial are:

  1. CSVI Pro 5 beta 1 or higher
  2. This attached XML file

Analyzing the XML file

Open the attached XML file in an editor. There are a few things to see:

  1. Root element
  2. Node element
  3. Record element
  4. Item element

Root element

The root element is the <catalog> tag in the file. This contains all the node and record elements. CSVI does not use the root element so we can forget this one.

Node element

The node element is the <products> tag in the file. This contains all the record elements. CSVI does not use the node element either so we can forget this one also.

Record element

The record element is the <product> tag in the file. This contains all the details of the item in our case. The record element is very important for CSVI, this is how it identifies where to start reading your file. Therefore we need to put the record element in the XML options in the template as shown here. The element is written without the brackets.

XML options record name

Item element

The item elements contain all the item information. This is what we need for setting up the template fields but more about that later.

Setup an import template for the XML file

First create a new template by taking these steps:

  1. Go to Components -> CSVI Pro -> Process
  2. Under Which import/export do you want to do? make the following selection:
    1. Import
    2. VirtueMart
    3. Product import
    4. Click on Go
      Select import export
  3. On the File tab, set Use column headers as configuration to No
    Template options file
  4. Now save the template by clicking on the Save as new button. This step is needed so we can add the fields to the template.
    Template save
  5. The template is now ready to be configured

Adding the fields

The most important part of the template are the fields, this is where CSVI is told what to do with the import fields. The order of the fields is not important as CSVI identifies fields based on their name. There is only one case where the order is important, that is with fields with the same name, this will be explained later. All field names are case-sensitive. Pay attention to this. We will take the following steps:

  1. Identify the XML paths
  2. Identify the CSVI fields
  3. Add the fields to the template
Identify XML paths

A field name is created by CSVI based on the path in the XML file, the path always starts from the item element. First we will create the path names of the items in the attached XML file.

  1. Element: <ID>
    Path: ID
  2. Element: <NAME>
    Path: NAME
  3. Element: <DESCRIPTION>
    Path: DESCRIPTION
  4. Element: <PRICE>
    Path: PRICE
  5. Element: <PRICE_BASE>
    Path: PRICE_BASE
  6. Element: <PRICE_RES>
    Path: PRICE_RES
  7. Element: <IMAGE><IMAGE1>
    Path: IMAGE/IMAGE1
  8. Element: <IMAGE><IMAGE2>
    Path: IMAGE/IMAGE2
  9. Element: <IMAGE><IMAGE3>
    Path: IMAGE/IMAGE3
  10. Element: <IMAGE><IMAGE4>
    Path: IMAGE/IMAGE4
  11. Element: <VIDEO1>
    Path: VIDEO1
  12. Element: <VIDEO2>
    Path: VIDEO2
  13. Element: <VIDEO3>
    Path: VIDEO3
  14. Element: <FEATURES><FEATURE name>
    Path: FEATURES/FEATURE/NAME
    This path is used multiple times for the other features
  15. Element: <FEATURES><FEATURE>
    Path: FEATURES/FEATURE
    This path is used multiple times for the other features
  16. Element: <SIZE>
    Path: SIZE
  17. Element: <GROUPPRODUCTS>
    Path: GROUPPRODUCTS
  18. Element: <STATUS>
    Path: STATUS
  19. Element: <CATEGORY>
    Path: CATEGORY
  20. Element: <BARCODE>
    Path: BARCODE
Identify CSVI fields

Now that we have all the paths identified we need to identify the CSVI fields the paths belong to. A visual guide is available for the fields name to help you identify the fieldnames. Hereby the list of fields for the example XML:

  1. Path: ID
    CSVI: product_sku
  2. Path: NAME
    CSVI: product_name
  3. Path: DESCRIPTION
    CSVI: product_desc
  4. Path: PRICE
    CSVI: product_price
  5. Path: PRICE_BASE
    CSVI: skip
    This field is skipped because there is no equivalent field available, this applies to all fields being skipped.
  6. Path: PRICE_RES
    CSVI: skip
  7. Path: IMAGE/IMAGE1
    CSVI: file_url
  8. Path: IMAGE/IMAGE2
    CSVI: combine
    This field is going to be combined with the file_url field because there is only 1 field available to specify images.
  9. Path: IMAGE/IMAGE3
    CSVI: combine
  10. Path: IMAGE/IMAGE4
    CSVI: combine
  11. Path: VIDEO1
    CSVI: skip
  12. Path: VIDEO2
    CSVI: skip
  13. Path: VIDEO3
    CSVI: skip
  14. Path: FEATURES/FEATURE/NAME
    CSVI: custom_title
  15. Path: FEATURES/FEATURE/NAME
    CSVI: combine
  16. Path: FEATURES/FEATURE/NAME
    CSVI: combine
  17. Path: FEATURES/FEATURE
    CSVI: custom_value
  18. Path: FEATURES/FEATURE
    CSVI: combine
  19. Path: FEATURES/FEATURE
    CSVI: combine
  20. Path: SIZE
    CSVI: skip
  21. Path: GROUPPRODUCTS
    CSVI: skip
  22. Path: STATUS
    CSVI: published
  23. Path: CATEGORY
    CSVI: category_path
  24. Path: BARCODE
    CSVI: skip
Add the fields

Now that we have identified the paths and fields, we are ready to add all the fields to the template. We do this by following this procedure:

Template options field

  1. Click on the Fields tab to open the fields section
  2. From the Field name dropdown select the CSVI field
  3. In the File field name field typ the XML path. Do not forget that the file field name is case-sensitive.
  4. Click on the Add symbol
  5. Repeat these steps for all fields
Combine fields

The next step is to configure the combine fields to make sure all the fields get combined.

Template field edit

As mentioned earlier, we are going to combine the image fields because there is only 1 field for an image available. To combine the images we need to edit the field name, this is done by clicking on the field name. The steps are:

  1. Click on the field name file_url
  2. An edit screen opens as seen on the screenshot above
  3. Next to the combine option select all the fields you want to combine with the current field. We have 4 images in total, the first one is linked to the file_url field and the other 3 need to be combined with the first one. In the list of combine fields select the other 3 images as shown. In the screenshot the images are in consecutive order but that is because the fields were added this way. This is not a requirement.
  4. Next in the Combine character we need to set which character we want to use to combine the fields. Multiple images are always separated by a pipe-symbol |, so we fill in the pipe-symbol.
  5. Click on Submit to save the changes
  6. Do the same for the custom_title and custom_value fields as shown below:
    Template field edit custom titleTemplate field edit custom value
  7. The fields are now all added and set up

 How to import the XML file

 The last step is to import the XML file.

Template select file

  1. Under source options select Load from computer
  2. Click on Choose File (text may vary depending on the browser used)
  3. Select the file on your computer
  4. Click on Process in the top left corner
  5. CSVI will now start to import the XML file

TESTIMONIAL

This is a must have component
5 stars
2012-07-30
I purchased CSVI Pro some time ago. My shop with over 25000 items will be on the run soon. I had a few questions to developers and support was very friendly, though I am not a big master in web-programming. Without CSVI Pro it would never happen. I tried before some free components, but it turned out that it was not an option.

Many thanks to Roland and keep on good work, guys. I would never hesitate to buy any new development and extend my subscription.

STAY INFORMED


Stay informed with the CSVI newsletter.