How to import & export Magento 2 categories with custom separators

- Magento 2, Our extensions

Magento 2 Development; Magento 2 tutorial

Since category names on an e-commerce website may contain commas, the export process may recognize them as separators, creating new categories in your export file. The same issue impacts your category tree on import: since the comma is considered a delimiter, a long category name can be split into several new categories. Below, we explain how to import and export Magento 2 categories with custom separators to avoid these issues. As usual, you will need the Improved Import & Export extension for Magento 2 since the platform’s default data transfer instruments do not support category import or export, nor it lets you use custom separators for category names when you import and export products.  

How commas impact product import & export in Magento 2

Since exporting products does not escape commas in category names, merchants often argue that category names get split at the comma when importing, and new categories are created. For instance, you sell goods for the triathlon on your Magento 2 website, and one of your categories is called “Swimming, Cycling, & Running”. Upon import, this category is considered three separate categories because the category title contains two commas: 

  • Swimming
  • Cycling
  • & Running

Therefore, merchants look for a solution to escape a comma in a category name and ensure products are imported correctly. 

How to import & export Magento 2 categories with custom separators

To address the comma issue, export products with a custom category separator like “;” and import them with the same delimiter. In this situation, extra categories will not be created. And that’s exactly what the Improved Import & Export does. 

The extension adds new fields for category separators:

  • Category Levels separated by;
  • Categories separated by.

Let’s see how to export Magento 2 categories with custom separators to illustrate the feature:

  1. Create a new export job under your Magento 2 Admin -> System -> Export Jobs.
    create a new export job to export categories with custom separators
  2. Configure its export settings, store filters, source, notifications, etc. 
  3. In Export Behavior, specify your custom separator in the “Categories separated by” field.
    Now, your category names that contain commas won’t be split into new categories.
    specify custom separator for category names on export

Now, you can launch your export job to export Magento 2 categories with custom separators.  You can also specify what separator to use for category levels.

If you want to import Magento 2 categories with custom separators, create a new import job and to the same preparations, specifying your custom category separator in the “Categories separated by” field. 

As a result, category names such as “Swimming, Cycling, & Running” won’t be split into multiple categories. In addition to that, the Improved Import & Export extension offers dozens of useful features and time-savers, such as mapping or automated data transfers. But let’s start from the very beginning.

You can use the Improved Import & Export extension to work with numerous file formats. While Magento 2 supports CSV files only, our module lets you import and export data via CSV, XML, JSON, XLSX, etc. As a result, it’s not necessary to convert files to CSV before importing them to Magento 2! Along with that, the plugin lets you transfer data between your e-commerce website and various file sources, such as Dropbox or Google Drive. 

And as we’ve just mentioned above, the extension lets you create cron-based schedules to automate data transfers. The module also offers a user-friendly mapping interface where you can match unsupported attributes to the ones Magento uses.  

Apart from that, you can use Improved Import & Export to transfer data from Google Sheets or establish API-based connections between your Magento 2 store and any external system. Follow this link to find more information about the module: 

Get Improved Import & Export Magento 2 Extension

Also, check our Magento 2 Cookbook for more useful tips.