How do you export and import selection attribute options using CSV in AI Commerce ?
Learn how to export and import attribute selections using a CSV file efficiently and without errors.
This article discusses exporting and importing the options (Options) of selection attributes using a CSV file. This is useful when you want to manage the translations of attribute options, add new options, or update existing ones flexibly. The instructions apply to attributes whose input type (frontend_input) is defined as either select or multiselect . An example would be the brand attribute, where the options are “sram”, “scott”, “bbb”, etc.
Below are step-by-step instructions for exporting and importing, as well as example files, structures, and typical error situations.
1. CSV Export Options (export logic)
- Go to Products > Attributes > CSV Export Options .
- Click the "CSV Export Options" button.
- The system creates a CSV file of all attributes that have a select or multiselect input type.
The file contains the following fields:
code
- Option code that uniquely identifies the selection.
- Required for CSV updates: this is used when the system decides to create a new one or update an existing one.
title[fi], title[en], ...
- Translations into different languages. Each language is imported into the column
title[xx]
, wherexx
is the language code (e.g. fi, en, sv). - A CSV can have multiple of these columns, one for each language.
attribute
- A column that tells which attribute the selection belongs to (e.g. brand).
- Only attributes with frontend_input of select or multiselect accept options.
sort_order
- An integer that specifies the order of selection in the drop-down menu.
Example of CSV
A CSV file (separated by ;
) might look like this:
code;title[fi];title[en];attribute;sort_order
sram;SRAM;SRAM;brand;5
pro;Pro;Pro;brand;6
schwalbe;Schwalbe;Schwalbe;brand;7
ortlieb;Ortlieb;Ortlieb;brand;8
-
code
is always unique for each attribute selection. -
attribute
is the attribute that the selection applies to (in this example, brand ).
Feel free to edit the file in Excel/LibreOffice, as long as the column names remain exactly the same.
2. CSV Import Options (import logic)
- Go to Products > Attributes > CSV Import Options and select your CSV file.
- The system opens the file and validates the CSV structure (checks the headers and number of columns).
- Each line is examined using the following logic:
- code => option_code
- attribute => The system retrieves the attribute_code value. If the attribute's frontend_input is not select or multiselect , the row is skipped.
- title[fi], title[en], … => Fills in different language versions of the selection name.
- sort_order => Order number.
Adding a new option vs. updating
- If the CSV line contains
code
that is not found in the database for that attribute, the system will create a new option. - If
code
is already found for the same attribute, the system will update the existing option (including name/translations andsort_order
).
Required code
- Since the CSV file uses
code
to identify the selection,code
must always be present. - If
code
is missing or empty, the line is skipped or the import aborts with an error.
3. Column explanation
Column | Description |
---|---|
code | Unique code of the selection. For example, sram, pro, muc_off. |
title[en] | The name of the selection in Finnish. You can also add title[en], title[sv], etc. |
attribute | Under which attribute is this selection (e.g. brand, color). |
sort_order | An integer that specifies the order in the menu. |
Languages [fi], [en], [de], ...
You can use any language codes you want. For example, if your system language settings are Finnish (fi) and English (en), your CSV might include title[fi]
and title[en]
. If you want Swedish, add title[sv]
, etc.
4. Example table in HTML format
The HTML table below illustrates one possible CSV structure (separated by ;
) with four rows. The attribute is brand , and the options have code
, Finnish/English names, and sort_order
values.
code | title[en] | title[en] | attribute | sort_order |
---|---|---|---|---|
sram | SRAM | SRAM | brand | 5 |
professional | Pro | Pro | brand | 6 |
swallow | Schwalbe | Schwalbe | brand | 7 |
ortlieb | Ortlieb | Ortlieb | brand | 8 |
5. Typical error situations
Missing code
- The row cannot be updated or added because
code
is the only way to identify the option.
Attribute not found or not select/multiselect
- The row is skipped (or an error is reported). Only attributes with frontend_input of select / multiselect support selections.
Missing columns
- If the number of columns in the rows in the CSV does not match the header row, the import will stop with an error message or skip the row.
Missing title[fi] column
- It is not mandatory, but if you want a Finnish name, the column must be there. Correspondingly,
title[en]
for English, etc.
6. Workflow in a nutshell
Export existing options
- You will receive a CSV file with codes and translations ready.
Edit or add rows
- Always keep
code
unique within the same attribute. - Use
title[fi]
,title[en]
, etc. language columns as needed. - Set
sort_order
.
Import the file back
- The system creates new options or updates existing ones based on
code + attribute
combo.
Check for any error messages
- This ensures that all rows have been imported or updated successfully.
7. Summary
Options is an additional data structure for attributes with input type select or multiselect . Each option must have code
(required) and a target attribute
. Language-specific names are stored in columns title[xx]
. sort_order
determines the order of selections in menus. We recommend taking the Export file first and editing it to ensure the column structure is correct. When code
remains unique per attribute, updates and additions will be successful reliably.
Keywords
- CSV file
- attribute selections
- select and multiselect
- product attributes
- Import and Export
- Options management
- sort_order
- title[fi], title[en]