Navigation

3. Import Categories

v. 30.11.2010

This section describes how to perform category import to Magento from .csv file - bulk update Magento categories.

It's highly recommended to create database backup before Magento category import, especially if you do it for the first time. Pay attention to each Wizard's page when importing categories to Magento. Import may be destructive if performed incorrectly.

Important note: category can be created with automatically incremented ID only. That is why for creating new categories with Categories Import/Export Wizard you may use category identification method "by category name + category path" only. For updating your categories you may use both category identification methods: "by ID" and "by category name + category path". 


To import Magento categories follow few steps:

  1. First of all you need to do is to check/prepare a .csv file for Import.. Make sure it contains all necessary fields and all data you are going to import is listed in the table.

    If your vendor provides you category list in Excel, you can convert your Excel files to the CSV format within the Microsoft Excel or OpenOffice application by using the Save As option. You can then access the Save As dialog box which contains a list of alternative file formats. Among the file extensions offered, you can find Text CSV file format. By saving your file into CSV format, Microsoft Excel or OpenOffice will export the first active worksheet with the correct delimiters.

  2. Once you have your CSV file ready for import start Store Manager, open Categories Import/Export wizard and select Import.


  3. Specify the path to .csv file and its name or use browse button [...]  to select one.


    You can select necessary charset for current file using "File Charset" dropdown. You can specify more exactly which type of charset is using in your .csv file.

    You can also load import settings saved on the last step of import wizard used to import a file with similar formatting, column names etc.

  4. Source file preview shows a part of .csv file that was selected. There are no options to set, but you should pay some attention to this page. What's so important to look for on this page is fields delimiter and quote character, if some is used. Some files may have text enclosed in quotes, while numeric values may be unquoted.


    If you carefully check the second line of the example, you'll notice that some words enclosed in quotes (") and are separated by semicolon (;) symbol. That are two important options you have to pay attention to - you will have to setup these settings on the next page. Usually it is enough to see first line, no need to investigate entire file.
  5. Select fields delimiter and quote character. If you specify wrong values, import may not work.


    • Select Delimiter Character. Most popular delimiters are comma (,), semicolon (;) and tab character ( ) however other symbols can be used as well.
      Note. CSV file contains data in row-column format and delimiter character is used to separate one column from another. If you specify incorrect delimiter, file will not be parsed properly and categories will not be imported.
    • Quote string values delimiter will be used to separate strings in .csv file. This delimiter can be disabled if none are used.
    • Category delimiter. This is not native .csv setting, it is used only in Store Manager. As you know categories are organized in a form of tree, where parent category can contain one or more subcategories, and subcategory can contain one or more other categories. Category delimiter character is used to separate category names and specify full category tree path for given category. Category path is very similar to directory path used to specify full file name in Windows, where every directory separated by backslash (\) character like this one C:\Program Files\MagneticOne\Store Manager for osCommerce\. 
    • Import images. You have to select whether to import images and their names and specify image directory on your local PC to import images from. Note that you should configure FTP connection in Preferences -> FTP tab before import in order to be able to upload images to your server.
  6. Select Store View where you should like to import categories.


  7. The next page allows you to Link columns from .csv file to appropriate database fields.


    Specify the following options:

    • Category Identification Method - Magento Import Categories Wizard will search for a category using selected method of identification. The category will be modified if found, if not - new category will be added.
      Note: It is recommended to use Category Name + Category Path to identify your categories. As new category IDs are generated automaticaly when you Import categories to Magento for the first time (import ignores your Category IDs). If you used to Export data to .csv file for further import, you may use Category ID identification method, otherwise use Category Name + Category Path.
    • First row in .csv file contains field names but not values - Obviously it should be unchecked if first row of .csv file contains data, otherwise check this option.

    Link columns from .csv file to appropriate database fields. The left pane "Database Fields" shows the list of fields in your database that can receive import data. 

    Source .csv file can contain multiple records with identical Name values. All these categories will be considered as one - currently imported categories will overwrite previously imported with the same key field values. Note that sometimes one of key fields may be blank. Obviously blank fields contain the same value for all records. It is required to assign .csv columns to key fields.

    Database Fields contains such columns:

    • RecID - contains database field ID.
    • Field - contains database field name. Some values in this column contain actual field name, whereas other are "translated". Anyway these names are clear enough to figure out how to use them.
    • csv col - the number of the column in .csv file corresponding to this field - the link between database field and .csv column.
    • Expression - allows you to create SQL statements in the opening window. You can use SQL statements that return single value.
               

           To assign .csv column to database field you should select a field at the left pane and then click a column at the right pane.

    [Auto Set...] button - try to set correspondence automatically for all fields. Auto fill option will work only if .csv column name is the same as database field name ("translated").
    [Predefined] button - allows you to restore settings you've saved during import in import configuration file.
    [Clear] button - clear all "csv col" values at the left pane

    7. Base Formats and Separators are used to convert text values from .csv file to numerical and date values. You can just set default values using appropriate button.


        8. Categories were not imported to your database yet.

        On Preview Import page you can see how your .csv file was processed using all import settings. Check whether all columns that you want to be imported contain data as some of them may be blank, as you haven't assidned them or they are empty in source (.csv) file. Columns that were not assigned will not be imported whereas empty values will overwrite existing.


        Red blinking arrow will be shown to draw your attention. Check out all errors and fix them.

        9. Import options page may affect Import results. Please read and check your selection carefully.

        Import Method
        Add and Modify - will add new category if it is not available in database yet and modify those categories that were found
        Add Only - only add new categories
        Modify Only - only update existing categories and do not add new entries, even if current category was not found
        Just Add - this option may produce category duplicates, since Store Manager will not try to find existing categories but will only add all categories as new

        Save Import Configuration
        All import settings can be stored under some configuration. You can load it next time you decide to import categories to Magento from a file with similar formatting, column names etc.
        Attention! Import process will start, when you press "Import" Button! Proceed only if all settings are made, otherwise press "Back" Button and check settings once more!

        11. In the last window of Magento Import Categories Wizard you can see if any errors occurred during import.

        Most frequent import errors are date, time and number conversion issues, caused by improper format settings (specified at previous page) or improperly assigned column (i.e. if you assign column containing category ID to parent_category database field). Date/time conversion errors might be ignored whereas other errors like this one (Could not find image: image_name.gif) better to be fixed.