How to Import Multiselect Attribute Values to Magento 2

Magento 2 import export debug log

Recently, we came across an interesting issue on Stackexchange. Its author is wondering whether it is possible to create values for a multiselect attribute when you upload a CSV file. Below, we share two solutions: community-based and Firebear-proposed. To make a long story short, let’s explore the issue and describe how to import multiselect attribute values to Magento 2. More tips are available here: Magento 2 Cookbook.

'

Impossible to import multiselect attribute values to Magento 2

Bennychaos tries to figure out how to create values for a multiselect attribute by uploading a CSV file. The author needs to populate a new multiselect attribute “Year.” 

He provides a few sample entries as well as the additional_attributes data that look as follows:

However, the expected multiselect attribute values weren’t created in the system.

How to create multiselect attribute values via CSV

Franck Garnier reports that the discussed feature is not natively supported in Magento 2. However, the author offers a workaround to manage it. He adds new multiselect attribute options dynamically during CSV validation. The proposed solution works equally well for both manual import and Scheduled EE import. 

Franck points to the fact that you need to reload the attribute option cache for each line after every update, but it is not the biggest issue. The problem is that you need to create a new module so that this approach is aimed at coders only. Let’s see how to add multiselect attribute values by importing a CSV file according to the Magento community.

To create a new ImportExport module, you have to add the following dependencies in etc/di.xml first:

Next, Franck proposes to extend the following class

with this code: 

After that, you need to do similar manipulations over another class

Use the following code to extend it:

And the last step is related to this class:

You have to extend it with this code:

Although adding three code snippets looks quite simple, we don’t recommend you to do that if you don’t have the proper experience. You can rely on another method instead. We describe a more user-friendly solution to importing multiselect attribute values to Magento 2 that requires no programming skills.

How to import Magento 2 multiselect attribute values

As for the Firebear-proposed solution, it doesn’t force you to discover continents again. It is only necessary to install the Improved Import & Export module to import multiselect attribute values to your e-commerce website.

With our extension, you can freely upload Magento 2 product attributes, attribute sets, and attribute groups, controlling every single aspect. Of course, you can add new multiselect attribute values from a CSV table.  

Magento 2 product attributes EAV import and export

The Improved Import & Export extension simplifies the process of transferring any data to and from Magento 2 as well as lets you automate all import and export procedures. Furthermore, it is possible to import attributes and their values to Magento 2 from any external systems. Let’s explore the general algorithm. 

Your first stop after you install the plugin is situated under System->Improved Import/Export->Import Jobs. You have to click “Add New Job” and configure the settings described below.

 Magento 2 attributes import

The system redirects you to the General Settings tab. Here, you can activate your new import job, specify its title, and add a schedule of transfers. Use the latter if you want to automate all further updates. Next, choose a language (locale) and enable/disable several more features.

 Magento 2 attributes import

After that, you can proceed to the Import Settings section. Select attributes as your import entity, enable/disable API synchronization depending on your needs, and select a platform to import data from. This option applies a mapping preset that replaces third-party attributes with the corresponding local ones.

 

Proceed to the Import Behavior tab. Select how to act with the imported file: add, update, replace, or delete attributes you transfer. Next, specify a validation strategy and a maximum number of errors. The tab also lets you add any custom separators.

 Magento 2 attributes import

In the Import Source section, select a file format and an import source. You are no longer limited by CSV files and direct uploads. Or extension lets you transfer data via XML, XLSX, JSON, ODS from a local or remote server, URL, via direct uploads, or from Dropbox and Google Sheet. 

 Magento 2 attributes import

Hit “Save & Run” to add multiselect attribute values by importing a CSV file to Magento 2. 

Final Words

The Improved Import & Export Magento 2 extension lets you add multiselect attribute values without any new line of code. You just need to install the module to leverage its functionality. In addition to the ability to import and export entities that are not supported in Magento 2 by default, it also offers a bunch of robust improvements. Thus, you can entirely automate data transfers between your e-commerce website and external platforms with the help of schedules. 

The extension also lets you replace unsupported attributes and attribute values most easily. You can leverage either mapping presets or a matching interface. At the same time, several features are aimed at more efficient attribute values editing. And you can create lacking attributes on the fly. 

With the help of extended connectivity options, the Improved Import & Export Magento 2 plugin also lets you move updates via API or from Google Sheet, avoiding standard data file transfers. And as we’ve just mentioned, you are no longer limited to the CSV standard and direct uploads. For further information on how to add multiselect attribute values via CSV, follow the link below or contact our support right here:

Get Improved Import & Export Magento 2 Extension

'