How do you export and import categories using a CSV file?
Speed up bulk editing of categories by leveraging CSV export and import.
This article will walk you through how to both export and import categories for your AI Commerce online store using a CSV file. This allows you to efficiently create or update large numbers of categories, their language-specific information, and other settings without having to make changes one by one in the dashboard. This process is especially useful when you want to save time and ensure data consistency on a larger scale.
1. CSV Export Categories
With the export function (" CSV Export Categories ") you get a CSV file from the system, where each category has its own row. Each row contains:
- Category specific fields (e.g. code, image , etc.)
- Language-specific columns (e.g. name, description, meta-data ) for each language code
Example of headings
By default, a CSV row might have the following columns, for example:
categories_id;parent_id;parent_code;categories_code;cat_front_page_img;categories_image;cat_front_page_img_enabled;google_feed;categories_index;categories_thumbnails_view;categories_name[fi];categories_description[fi];categories_description_top[fi];categories_path[fi];categories_url[fi];categories_meta_title[fi];categories_meta_description[fi];categories_name[en];...
(and correspondingly for other languages [en]
, [sv]
, etc.)
Note:
- categories_code is the unique code for the category.
- parent_code is the code of the possible parent category.
- The categories_id and parent_id are visible in the export, but the categories_code and parent_code fields are usually used as identifiers in the import.
Example table in HTML format
Below is an example of a table with category column headings and a sample row. Keep the same column structure in your export and import file:
categories_id | parent_id | parent_code | categories_code | cat_front_page_img | categories_image | cat_front_page_img_enabled | google_feed | categories_index | categories_thumbnails_view | categories_name[en] | categories_description[en] | categories_description_top[fi] | categories_path[en] | categories_url[en] | categories_meta_title[en] | categories_meta_description[en] |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
14 | 1 | parent_cat | accessories | frontpage.jpg | cat_image.jpg | 1 | 1 | 1 | list | Accessories | All accessories... | Top text... | /accessories/ | http://site.fi/lisatarvikkeit | Accessories - Meta Title | A short meta description. |
The file produced by Export is in CSV format, with columns separated by semicolons ;
and the character set is, for example, UTF-8.
2. CSV Import Categories
In the import function (" CSV Import Categories "), the system reads the file line by line and updates or creates new categories according to the following rules:
categories_code
- Uniquely identifies the category.
- If the code is new, a new category is created.
- If the code already exists, the existing category will be updated.
parent_code (parent category code)
- If a value is given and recognized, the category becomes a child of this parent category.
- If parent_code is provided but not found, the system will also create a parent category with empty data (or ignore the value depending on the settings).
Language-specific columns (e.g. categories_name[fi], categories_name[en], … )
- Updates the TABLE_CATEGORIES_DESCRIPTION table. If the language row does not already exist, it will be created.
Other columns (e.g. cat_front_page_img, categories_index, categories_url[fi] )
- Updates the corresponding data fields if they have a value assigned to them in the CSV row.
About creating new language rows
If a new category is created, the system may automatically create empty language rows in the TABLE_CATEGORIES_DESCRIPTION table for each language. After this, only the languages in the CSV will be overwritten.
Note:
- If categories_code or parent_code is missing entirely, the row may be skipped or default values may be stored.
3. Important columns
- categories_code : Required, identifies the category.
- parent_code : Not required, but specifies the code of the parent category.
- categories_image, cat_front_page_img, etc.: Updatable fields for categories.
-
categories_name[fi], categories_description[fi] etc.: Multilingual names and descriptions. Always use the square bracket syntax
[kielikoodi]
.
4. Validation & common problems
Missing categories_code
- The line is skipped because a category cannot be created without code.
No match parent_code
- If a parent_code is provided but not found, the system may automatically create a new parent category or ignore the value depending on the configuration.
Column headings
- The CSV file must have exactly the same number of columns in each row.
- Multilingual fields must be marked in the format
[fi], [en], [sv]
, etc.
Language lines
- For example, if the CSV contains categories_name[fi] but not categories_name[en] , only the Finnish name will be updated.
- Metadata, URLs, and paths (e.g. categories_path ) can also be language-specific.
CSV Error
"CSV ERROR on line X: found Y columns, expected Z columns." This means that the line has the wrong number of columns – often due to an incorrect delimiter or missing quotes. The check stops the import so that only properly formatted data is saved. CSV import requires that columns are separated by semicolons (;) and values are enclosed in quotes ("). Make sure you are using an up-to-date base file!
5. Workflow
Export
- Start the export using the " CSV Export Categories " button. Download all (or desired) categories in CSV format.
Edit
- Open the CSV file in, for example, Excel or LibreOffice.
- Make the necessary changes: categories_code , parent_code , language translations, images, etc.
Import
- Press the " CSV Import Categories " button and upload the edited CSV file.
- The system updates existing categories or creates new ones based on the categories_code field.
- parent_code associates the category with its parent category, if one is defined.
Check error messages
- Pay attention to missing codes ( categories_code ), incorrect column count, or other possible messages.
6. Example CSV line
categories_code;parent_code;cat_front_page_img;categories_image;cat_front_page_img_enabled;google_feed;categories_index;categories_thumbnails_view;categories_name[fi];categories_description[fi]
accessories;catalog;front_image.jpg;cat_image.jpg;1;1;1;grid;"Lisätarvikkeet";"Kaikki lisätarvikkeet ja tarviketiedot..."
Commentary:
- categories_code=accessories : Code for this category.
-
parent_code=catalog : The parent category is
catalog
. If it does not exist, it will be created. - categories_name[fi] : Finnish name “Accessories”.
- categories_description[fi] : Finnish description.
7. Summary
Exporting and importing categories using a CSV file allows you to manage your store structure efficiently and flexibly:
- categories_code is always a required identifier.
- parent_code is optional, but specifies the parent category.
- Language-specific fields are marked
[fi]
,[en]
, etc. - It is recommended to start with Export , edit the CSV file, and then use Import to load the changes. This will ensure that the columns remain correct.
It's a good idea to first test with a small CSV file and make sure everything works as expected before making extensive changes to the production category framework.