This tutorial will explain how to import extra fields with the K2 Item import.
Go to Components -> CSVI Pro and click on Templates tab. You are now on the Templates page from where the import and export templates are created.
Preparing the template
Click on New on top left corner to create a new template for import.
- Give a descriptive name for the template say "K2 import"
- Set Enabled to Yes
- Enable logging to Yes to get debug log. This is a very important option. Setting this to Yes will tell CSVI to create a detailed log of all steps taken during import. This is a very useful report to find any potential problems. Whenever you post a question on the forum, make sure you post this file also. It is the only way to help you out. The How to collect debug information article explains this in further detail.
Under Operations select the following:
- Select Import
- Select K2
- Select Item
Save the template by clicking on Save or Save & Close.
Setting the file options
The next step is to tell CSVI something about the file you want to import.
- Auto detect delimiters
If your CSV file is using both the field delimiter and the text enclosure. You can set this to Yes otherwise it must be set to No and you can specify your own delimiters.
- I'm Mac
This is only needed if you are using a Mac computer and your file might be using Mac line-endings as opposed to Windows or Linux line-endings.
- Use File for configuration
CSVI can read the fields you want to import from 2 locations:
- Import file
- Template fields
If you set this to Yes, the first line from your import file will be used to read the fieldnames you want to import. If you set this to No, CSVI will use the fields you have specified on the fields tab. Important: the field names in your file must be valid CSVI fieldnames. Set this to No now for this tutorial.
- Skip first line
This can be used if you let CSVI take the fields from the template and not from the file and your file has your own column headers.
Now that the file options are set, CSVI knows how to read your file. Click on Save to save your changes in your template and make sure they don't get lost.
Adding the fields
Before we can use the Extra fields as defined in K2 for import, we must tell CSVI that there are extra fields. To do this take the following steps:
- Go to Maintainence Tab > Available Fields in CSVI
- Click on Update
After the update has finished, your extra fields will show up in the field list on the Fields tab and can be used for import and export. The name of the extra fields is combined of 2 parts:
- Name of Extra Field Group
- Name of the Extra Field
Each field name is separated by an _-symbol (underscore). The list will contain these 2 fields:
- CSVI_Place of sale
- CSVI_Date of sale
The next step is to add the fields we want to import to our template. To import properties there are a few fields that are really needed:
In addition you can add extra fields as you like. For example, we have 2 extra fields defined in the CSVI group as follows:
- Place of sale
- Date of sale
Let's tell CSVI which fields you want to import.
- Under the Field name column, select the field name
- The other options we leave empty as they are fine
- Click on the + symbol
- Repeat step 1 - 3 for all fields including the 2 extra fields
- Set the order of the fields in the Order column.
- This can be done manually by entering the correct order and then click Save
- This can be done automatically by clicking on the Reorder icon next to the word Order
To make sure we don't lose anything, click on Save to save your template.
If you do not know which fieldnames to use, check out the Visual Available Fields.
The fields then look like this:
Creating the import file
With the template ready it is necessary to create our import file. You can create your import in almost any kind of spreadsheet or text editor. There are a few things to look out for though. The file must:
- be UTF-8 encoded
- have correct delimiters
Let's create our CSV file. We are going to import an item with 2 extra fields.
"title";"alias";"category_path";"introtext";"CSVI_Place of sale";"CSVI_Date of sale"
"Discounts";"discounts";"News/Discounts";"<p>Find your latest discounts here.</p>";"Rotterdam";"2013-12-05"
Save these 2 lines in a file.
The item is going to be imported in the category:
This structure is found in the category_path field where each category is separated by a / (forward-slash). You will have to make sure that the group these extra fields are in is assigned to this category.
New values custom fields
If your import file contains new values for custom fields, they will be added as default value to the system. There is no need to first add them to your field
If I now import the value Yellow for the field Dictionary it will be added a default value here.
With our template configured and our file created, we are ready to import. Go to Import tab from Components >> CSVI Pro. Select the template name and click on Select file from top left corner.
Click on Choose file and select your import file. Then click on the Preview button in the top right hand corner. You will see the content of CSV file which is going to be imported.
When the import is done you will see a screen like this:
Here it says Updated but that can also be Added if the category doesn't exist yet. There you go, you have succesfully done a K2 Item Import.
The next thing you can do is, experiment. There are a lot of more features in CSVI you can use for example:
- Combine fields
- Replace fields
Other good sources of information are: