Magento 2 Categories Import & Export Guide

- E-Commerce, Magento 2

Today, we are going to talk about Magento 2 categories import and export. Unfortunately, the platform doesn’t let you import and export categories by default. Although its capabilities associated with data transfers are fairly limited, you can address the existing issues with Improved Import & Export. This extension provides the ability to import and export categories to Magento 2.

In the following article, we shed light on how to transfer an existing category tree to/from your e-commerce website using the Improved Import & Export Magento 2 extension. After describing the Magento 2 category export, we peruse a sample category CSV file. Then, our attention is focused on specific Magento 2 category attributes: we explore use cases and attribute mapping to let you transfer categories to Magento 2 from any external platform. Next, there is a detailed step-by-step guide that depicts Magento 2 categories import. Also, you will find out how to import product positions in categories (a part of the Visual Merchandiser functionality of Magento 2) and import Magento 2 categories per different store views. Let’s go!

What are Magento Categories?

In Magento, categories are organizational structures that allow you to group products to make it easier for customers to find them on your e-commerce website. They function as a navigation tool, helping users to browse products by type, function, brand, or other defining attributes. Magento categories also enhance SEO by enabling you to create specific category pages, which can rank for targeted keywords related to your product types.

Here’s a quick breakdown of how categories work in Magento:

  1. Hierarchy and Structure: Magento categories are structured in a tree format, where you can create parent and subcategories. For example, “Electronics” could be a main category, with “Laptops” and “Smartphones” as subcategories. This layered approach allows you to build a detailed and organized catalog.
  2. Product Assignment: Products can be assigned to one or multiple categories, letting you cross-promote items in different sections of your store. For example, a “Bluetooth Speaker” could be listed under both “Electronics” and “Audio Equipment.”
  3. Improved Navigation: Magento categories serve as a foundation for navigation menus. With well-structured categories, customers can easily find the products they’re interested in without relying on search alone.
  4. SEO Benefits: Each category in Magento can have its unique URL, metadata, and description, which helps improve search engine visibility. By optimizing category pages with relevant keywords, you can drive more organic traffic to your site.
  5. Dynamic Content Options: Magento allows you to add custom images, banners, and CMS blocks to categories, enhancing the visual appeal and providing additional information to engage customers.

Thus, Magento categories offer additional flexibility to suit various business models, whether you’re running a small catalog with a few main product types or a complex store with thousands of items across a huge category tree.

As previously mentioned, Magento 2 does not offer a built-in option to import or export categories. However, there’s no need to worry! Below, we’ll teach you to overcome this limitation with the help of the Improved Import & Export extension.

How to Export Categories in Magento 2

Before diving into the Magento import of categories, it’s essential to obtain a sample category CSV. The easiest way to do this is by exporting categories directly from your Magento 2 site.

To export categories, go to System > Export Jobs and follow these steps:

  1. Create a new export job and decide on its frequency;
  2. Select the ‘Entity‘ you want to export – ‘Categories‘;
  3. Decide on file format – CSV, XML, Excel, JSON, etc. – and field separators for the table, in case you are using different from native Magento 2;
  4. Choose a source to export Magento 2 categories: FTP/SFTP, Google Drive, manual download, Google Sheets, etc.
  5. Apply necessary attribute mapping and filters if applicable.
    magento export: categories
  6. Once done setting up the export job, click the ‘Save and Run button at the upper right corner of the screen.
  7. Next, hit the ‘Run‘ button to export categories from Magento 2.

As a result, you will get a CSV table with all Magento categories available at your store. At the same time, there is another way to get a sample categories CSV file.

Sample CSV for Magento 2 Categories Import

If you prefer not to export categories from Magento 2, you can refer to a sample import table instead. Reviewing the import table will give you insight into the required Magento 2 category attributes and the expected category structure. You can find the sample Magento 2 categories import CSV in two locations:

  • GitHub – proceed to the FIreBear Studio GitHub and download the file with the required entity type;
  • Google Sheet Master Table – The Improved Import and Export extension supports Google Sheets as an import source. That’s why we have composed a Google Sheet Master Table that includes all import entity types along with descriptions and sample values.

Sample import tables from both locations have been tested and work properly. Feel free to download and edit the tables to your liking, or copy the Master Table to your Google Drive. Read more about Google Sheet Master table

Magento 2 Categories Import Table Structure

Now that we have the sample table, it is time to talk about its formatting. Improved Import and Export extension allows you to use two table file formats: CSV and XML.

Note that your table should be properly formatted before import. If for some reason you have decided to create an import table manually – make sure to use the following settings:

Character set Unicode (UTF-8)
Field separator Comma (,), Tab (\t )
Text delimiter double quotes (“)

Note that a tab can be used as an alternative delimiter instead of a comma. This format is often called a TSV (Tab-Separated Values) file. When using tabs as delimiters, each piece of data is separated by a tab character (\t) rather than a comma. This can be helpful when the data itself contains commas, reducing the need for quoting fields and making the file easier to read.

If you want to import a Magento 2 categories CSV file with different formatting, the Improved Import and Export extension allows you to map fields and value separators manually. We will talk about this later in this post.

Magento 2 Import & Category Attributes

Now that we have a CSV table with the categories, let’s break it down to see which attributes are used to import categories to Magento 2, and which values are expected for the successful process.

Attribute Name Reference Values Value Example
entity_id The identifier for categories within Magento 2.

You can find a category ID next to the category name at Catalog > Categories

Numeral value 12
name Category name. The category name contains the full category path, including all parent categories For example:

If you have a category named ‘Third’ which is nested under the ‘First’ and ‘Second’ categories, the name value will look like this:

First/Second/Third

Use ‘/’ to separate category names

Default Category/First test category
store_view Defines the store view where the category is displayed under the current name.

Store View Code can be found under Stores > All Stores > next, click required store view and check the “Code” column.

Can contain letters and numerals with spaces and hyphens eng-store

English Store

image The main category image and its path Should be uploaded to /pub/media/import.

The path of /sample_data/m/b/mb01-blue-0.jpg has the following structure: /pub/media/import/
sample_data/m/b/
mb01-blue-0.jpg

In addition, you can use a direct URL of an image, such as http://site.com/images/
some_image.jpg

/pub/media/import/
category_images/
image1.png
url_path Category URL path at the front end. This attribute creates a URL rewrite to compose the end category URL The end category URL is composed of the following pattern:

yourstore.com/index.php/
url_path attribute value/
url_key value

For example:

If you want the category path to include category1 and category2. In this column, you need to enter:

category1/category2/. Use / to separate categories.

In this case end category URL will look like this:

yourstore.com/
index.php/category1/category2/
url_key value

test_parent_category/
test_sub_category
available_sort_by Category option Default Product Listing Sort By. Which defines which sorting options are available at the category page Available values:

blank – all values

position – product position

name – product name

price – product price

Multiple values should be separated by a comma.

For example, if you want only position and price sorting available the value should look like this:

position,price

position,name,price
custom_apply_to_products Category option Apply Design to Products. Defines if the custom category design should also be applied to the products belonging to the category Available values are:

Yes – Apply Design to Products enabled

No – Apply Design to Products disabled

Leave blank if no custom design is applied

Yes
custom_design Category Design > Theme option. Defines the theme that should be applied to the category The value should be the required theme name. Leave blank if no design updates are required, and the category should be displayed in the default theme applied to the store Magento Luma
custom_design_from Defines from what date the custom design should be applied to the category The date should be in the following format:

mm/dd/YY

For example:

If you want a custom design applied from the 10th of July 2019, the value should look like this:

7/10/19

2/1/18
custom_design_to Defines to what date the custom design should be applied to the category The date should be in the following format:

mm/dd/YY

For example:

If you want a custom design applied to the 10th of July 2019, the value should look like this:

7/10/19

2/28/18
custom_layout_update Category Design > Layout Update XML option The value should be in readable XML if you want any XML layout updates applied <referenceContainer name=\catalog.leftnav\” remove=\”true\”/>”
custom_use_parent_settings Category Design > Use Parent Category Settings option. Defines whether the category should copy parent category design settings Available values:

Yes – the category will copy parent design settings

No – the category will have a unique design

No
default_sort_by Category option Default Product Listing Sort By. Defines which sorting order should be applied to the products by default Available values:

Position – the products will be sorted depending on their position in the category.

Product Name – the products will be sorted in alphabetical order.

Price – the products will be sorted from lowest to highest and vice versa price

Product Name
description Category description Supports simple HTML formatting <p>Category description</p>
display_mode Category option Display Mode. Defines which entities should be displayed at the category page Available values:

Static block and products – both static blocks and products displayed

Static block only – only static blocks displayed

Products only – only products displayed.

Only a single value can be entered at a time. No multiple values allowed

Static block and products
filter_price_range Category option Layered Navigation Price Step. Defines the price step which will be used in the layered navigation Only numerals allowed 10
include_in_menu Category option Included in Menu. Defines if the category should be included in the main category menu Available values are:

Yes – category included in the menu

No – category is not included in the menu

Yes
is_active Category option Enable Category. Defines if the category is active or disabled Allowed values are:

Yes – the category is enabled at the frontend

No – the category cannot be found at the frontend

Yes
is_anchor Category option Anchor. Defines if the category is an anchor category or not Available values are:

Yes – the category is anchor

No – the category is not anchor

Yes
landing_page Category option Add CMS Block. Defines which CMS block should be included in the category The value should be the name of the CMS block. Only a single CMS block can be included. Multiple values are not allowed Contact us info
meta_description Meta description of the category Can contain any symbol Category meta description
meta_keywords Meta Keywords of the Category Can contain any symbol. Multiple values are separated by a comma category,meta, keywords
meta_title Meta Title of the category Can contain any symbols Category meta title
page_layout Category option Layout. Defines the layout of the category Available values are:

blank – no layout updates

Empty

1 column

2 columns with left bar

2 columns with right bar

3 columns

3 columns
position Category position in the parent category. From top till bottom. The lower the value the higher the category’s position.

Affects the order in which categories are displayed on the menu

Numeric value 10
url_key Category option URL Key. Defines the URL of the category All characters and symbols that can be used for URLs test_category_path
group String or integer same for a group of categories per store view.

Use the attribute to create a new category during the import

Numerals 1039

Category Attribute Mapping

If you receive an import table for Magento 2 categories import from a source different than Magento 2, you will need to compare the provided attribute (column) names and values with the ones described above. Usually, it is a manual process that takes place in a spreadsheet editor. However, you can skip renaming the attributes manually and take advantage of the Improved Import and Export extension‘s attribute mapping.

The module lets you select a Magento 2 category attribute and set the reference column from the import table. In such a way, you only need to match third-party names to the default namings of Magento 2. No editing is required because the extension communicates proper attribute names to Magento 2 during the category import process. We will talk about attribute mapping more as the post goes on.

Now, that you have learned that category import attributes are used in Magento 2, it is time to proceed to the actual import of categories.

Magento 2 Categories Import Step-by-step Guide

The Magento 2 categories import process takes place under System > Improved Import / Export > Import Jobs of your Magento admin.

The Import Jobs is the main import management screen where you can add new and edit existing jobs.

To create a new job, click the ‘Add New Job’ button. Next, follow these steps to import categories to Magento 2:

Step 1: Name Your Job & Set up Automation

The New Job screen will greet you with the General Settings section.

Start the magento csv import of multiple categories by naming your jod and automating the process

The settings are pretty much self-explanatory: name your job and create a schedule of updates if you plan to automate your category imports to Magento 2. Keep in mind, that you can always run your import job manually. Next, you will need to select the locale of the store you will be importing to.

There will be two settings left:

  • Generate Unique Url if Duplicate – allows you to increment the category URLs if the URL is already taken;
  • Re-Index after Import – allows re-indexing the store after the entity has been imported.

Step 2: Select Categories as Your Import Entity

When done with the general settings, you will need to select the entity you are going to import. In our case, it is ‘Categories’. Just choose it from the dropdown.

Select 'Categories' as your entity to import to Magento 2

Then, you need to select what the extension should do with the entities from the import table:

  • Add/Update – add new categories and update the existing ones;
  • Replace – replace categories with new ones;
  • Delete – delete categories matching the ones in the import table.

choose behavior for Magento categories import

After selecting the behavior, you can specify the validation strategy – whether the extension should skip or stop the process if any errors occur. This will help you understand if anything is wrong with your import table.

NOTE: pay close attention to Categories separated by and Category levels separated by settings.

  • Categories separated by – when you import products, you can decide which separator you use for the categories column. By default comma is used to separate multiple category paths. However, if you have commas in category names you may want to use different separators for category paths.
  • Category levels separated by – when you import products, you can decide which separator you use for the categories column to separate category levels. By default “/” is used to separate multiple category levels. However, if you have “/” in category names you may want to use different separators for category levels.

This is how the extension allows you to adjust the import table formatting by setting field and value separators.

Step 3: Choose Your File Format & Source

On the Import Source screen, select the import table file format and specify the source you will be importing from. In the screenshot below, we are using a direct link to the Google Sheet with our CSV table uploaded. But you can also import categories to Magento 2 via XML, JSON, Excel, and ODS files. As for sources, our extension supports a plethora of them, including FTP/SFTP uploads, Google Drive transfers, API integrations, etc.

Specify file type and source to import categories to Magento 2

When the source is specified, click the ‘Validate file’ button to let the extension check the integrity of the import table.

Step 4: Map Attributes to Import Categories from Any Source

Once the Magento 2 categories import table has been validated, you are presented with the Map Attributes section. It looks pretty straightforward:

map category attributes to import categories from a third party to Magento 2

In the Map Attributes section, you can set the reference between category attributes used by your Magento 2 store and the ones you are using in your import table. This is particularly useful if you got the import table from another ecommerce platform or composed it manually without considering proper category attribute naming.

That’s it, now you only need to click the ‘Save & Run’ button to import categories to Magento 2. Once you hit the ‘Run’ button, the extension displays the import job log, where you can immediately detect any errors.

You have just imported categories to your Magento 2 store using the Improved Import and Export extension. As you can see, there is nothing difficult in importing Magento 2 categories. You need to spend some time preparing attributes, but the import process itself is pretty straightforward.

Magento 2 Import of Categories: Use Cases

Below, you can see a couple of specific use cases for the Magento 2 import of categories associated with the Improved Import & Export module:

  1. Automater url_key Generation. The extension functionality can fill empty fields for url_key and url_path automatically. If you import a table without these values, Improved Import and Export will create the category URL based on its title (using a hyphen for each space in the name).
    E.g.: New Category — new-category
    In case you run import with the ‘Replace’ behavior, implemented categories with the matching names will be assigned with the increment +1 to enter the database with a unique URL.
    E.g.: new-category > new-category1
  2. Per-Store View Import. Use the Improved Import and Export extension to import categories for each store view with unique languages, names, and paths. To assign categories as variations per store view, utilize the “group” attribute. Since this functionality uses the “entity_id” attribute to handle existing categories for each store view, double-check the IDs during re-export to ensure they match those in your database.
  3. Automated ID Generation. To import new categories, leave the “entity_id” attribute column empty or delete it entirely. Magento 2 will automatically assign IDs to new categories.
  4. Updates of Existing Categories. If you need to update data in existing categories, start by performing a primary export to obtain the IDs of those categories. When making updates to the category data, be careful not to change the “entity_id” attribute, as it’s essential for accurate category processing in Magento 2.

How to Import Magento 2 Product Position in Category

You can also import product positions in categories to Magento 2. However, this information can be transferred along with products, not categories.

Below, we cover a product attribute introduced by the Firebear Team for the Improved Import and Export extension responsible for importing and exporting a Magento 2 product position in a category.

To import positions within a category, use the categories_position attribute. Note that it only works for the Improved Import and Export extension.

This is a custom attribute, and it will not work with the native Magento 2 import. Add the categories_position attribute to your product import table like in the example below:

magento 2 product position in category in CSV

The categories_position attribute mirrors the value of the categories attribute. However, you need to specify the position of the product after every category path.

Let’s suppose, we have the following category path in the categories attribute:

Default Category/Gear/Bags

Our goal is to specify that the product’s position in the ‘Bags’ category is 5. We need to add ‘=5’ to the category path in the categories_position attribute as follows:

Default Category/Gear/Bags=5

You can refer to the screenshot above to see how it looks in a CSV table. That’s pretty much it. Use this pattern to import a Magento 2 product position in a category.

And don’t forget that it is a part of the product import. Therefore, select Products as your import entity when creating a job for importing product positions in categories to Magento 2.

import magento 2 product position in category - select products as entity

After that, configure the import job as you would normally do. You can find more information about import jobs here: Improved Import & Export Manual.

Importing Magento 2 Categories for Different Store Views

Importing categories for multiple store views requires a different approach, as each store view can have unique category names.

For this reason, we must identify multiple rows of the same category, each with a different name, during the import process. Rather than using the “name” attribute for identification, this method allows for assigning distinct names per store view.

See the example file for multistore category import for Magento 2

For secondary store views or store views in different languages, submit the category name using the “store_name” attribute along with any other necessary category attributes.

Magento 2 categories import per store view using unique category names per each store view

The “store_name” attribute should contain the final category name in the path. For example, you have a category path like Category A/Subcategory A/Subcategory B. Place the translation of the last category in the path – in this case, “Subcategory B” – into the “store_name” attribute per specific store view. In the image above, the category name is set as “1 Premier categorie” for the French store view and “1 Erste Kategorie” for the German store view.

If you want to translate “Subcategory A” instead, then enter this path in the “name” attribute: Category A/Subcategory A. Then, specify the new name for “Subcategory A” in the “store_name” attribute.

Key Tip: When importing categories and translating or updating category names for multiple store views, use the “store_name” attribute to modify the name of the last category in the path defined in the “name” attribute.

How to Rename Magento 2 Category for Default Store View During Import

Renaming categories during Magento 2 import works the same as importing alternative category names for different store views, with a single exception: leave the “store_view” column empty. See this screenshot:

CSV to Rename Magento 2 Category for Default Store View During Import

In the second row of the table, you’ll see that the new name – “NEW CATEGORY NAME” – is specified in the “store_name” attribute, but the “store_view” attribute cell is left empty. After importing this CSV to Magento 2, the original category name, “1 First category“, will be replaced with “NEW CATEGORY NAME“.

If you leave both “store_name” and “store_view” empty – nothing happens.

Also, note that only the last category in the path specified in the “name” column will be renamed.

Follow these steps to rename categories via Magento 2 import:

  • Step 1: Export categories and open the file for editing;
  • Step 2: Add the store_name column to the file, the position of the column doesn’t matter;
  • Step 3: In line with the category you want to rename, fill in the desired name in the store_name column;
  • Step 4: Import categories back to the store.

That’s it! You’ve successfully renamed the category in the default store view using the Magento 2 categories import. For more information, contact Firebear.

Final Words

Although, the Magento 2 categories import is not available as a platform’s built-in functionality, you can easily add it to your store with the Improved Import and Export extension. There is nothing difficult in importing categories to Magento 2. Our extension even lets you import unique category names bound to specific store views. Besides, you can use the module to rename categories via the Magento 2 import process or transfer products along with their category positions. In addition to that, the Improved Import and Export extension offers numerous handy features described in our Magento 2 import/export guide list and on the extension’s page:

Explore Improved Import & Export Extension for Magento 2

Magento 2 Categories Import/Export FAQ

How to import categories to Magento 2 automatically?

Use the Improved Import & Export Magento 2 extension to import categories to Magento 2 automatically. The module relies on cron to automate data transfers. Consequently, you can create schedules to import product categories to Magento 2 automatically after certain intervals. For instance, you have two e-commerce websites with a similar category tree. Instead of applying updates to both of them manually, you can edit one of the stores and import new categories from it to the remaining storefront.

How to export categories from Magento 2 automatically?

You can also use the Improved Import & Export Magento 2 extension to export categories to Magento 2 automatically due to cron and automated data transfers. Following the example from the previous question, use the module to export categories from a store where you’ve just applied changes. It will help you import new categories to the remaining storefront.

How to import Magento 2 categories from Google Sheets?

You can use the Improved Import & Export Magento 2 module to import categories from numerous sources, including Google Sheets. The extension provides the ability to choose the desired storage when you configure an import profile. Just select Google Sheets as your data source and specify the URL address of a file with categories to import the corresponding update to your Magento 2 website.

How to import Magento 2 categories from Dropbox?

In addition to Google Sheets, you can also transfer a category tree to Magento 2 from Dropbox. Provide the address details of a file stored there and the Improved Import & Export extension will easily move it to your e-commerce storefront. Note that it should be a CSV, XML, ODS, XLSX, or JSON file. You can provide them in a compressed state as ZIP or TAR archives.

How to import Magento 2 categories from a CSV file?

You can use the Improved Import & Export Magento 2 extension to import categories via a CSV file. Follow the instructions mentioned in this article to configure the corresponding import process. Choose a CSV file as your import file type.

How to import Magento 2 categories from an XML file?

You can use the Improved Import & Export Magento 2 extension to import categories via an XML file. Follow the instructions mentioned in this article to configure the corresponding import process. Choose an XML file as your import file type.

How to import Magento 2 categories from an ODS file?

You can use the Improved Import & Export Magento 2 extension to import categories via an ODS file. Follow the instructions mentioned in this article to configure the corresponding import process. Choose an ODS file as your import file type.

How to import Magento 2 categories from an XLSX file?

You can use the Improved Import & Export Magento 2 extension to import categories via an XLSX file. Follow the instructions mentioned in this article to configure the corresponding import process. Choose an XLSX file as your import file type.

How to import Magento 2 categories from a JSON file?

You can use the Improved Import & Export Magento 2 extension to import categories via a JSON file. Follow the instructions mentioned in this article to configure the corresponding import process. Choose a JSON file as your import file type.

How to import Magento 2 categories in a ZIP or TAR archive?

You can use the Improved Import & Export Magento 2 extension to import categories in a ZIP or TAR archive. Note that they should be stored in a CSV, XML, ODS, XLSX, or JSON file.

How to import Magento 2 categories via API?

You can use the Improved Import & Export Magento 2 extension to import categories to Magento 2 via API. The module provides the ability to create a direct connection between the two systems so that you avoid the use of intermediate data exchange points and file transfers.

How to export Magento 2 categories via API?

You can use the Improved Import & Export Magento 2 extension to export categories to Magento 2 via API. The module provides the ability to create a direct connection between the two systems so that you avoid the use of intermediate data exchange points and file transfers.

How to export products by categories from Magento 2?

The Improved Import & Export module also lets you export products by categories from Magento 2. It is only necessary to create export filters and specify a category that contains products that you want to export.

How to assign Magento 2 products to categories on import?

You can use Improved Import & Export to assign products to categories while importing them to your e-commerce website. The module offers a mapping interface where you can select new categories for imported products.

How to map categories in Magento 2?

As mentioned above, you can use Improved Import & Export import profiles to map the imported categories to those available on your front end. Specify an imported category and select your store category in front of it. Thus, you map external categories to the ones used in your Magento 2 installation.