How to import customers to Magento 2 and assign them to a customer group
Chances are, you know a situation when it is necessary to import customers to Magento 2, but they are not assigned to a customer group. You need to re-assign them manually in this situation. The more cusomers your data file consists of, the more time you have to spend doing this data entry routine. But what if this process could be automated?
Below, we explain how to import customers to Magento 2 and assign them to a customer group even if this customer group doesn’t exist on your e-commerce website. All you need is Improved Import & Export. But let’s explore the issue in more detail before discussing the solution.
Magento 2 customer import doesn’t assign customers to customer groups
So, if you import customers to Magento 2 and they are not assigned to a customer group that exists on your website, your group_id attribute (the ID of this customer group) is probably empty. You can double-check your import file, apply the necessary changes, and then re-import it back. However, this approach doesn’t save you time.
In another case, your Magento 2 customer import process may not assign customers to a customer group simply because this customer group doesn’t exist on your website. In this case, you need to create it before importing any customer data and specify the group’s ID in the import file.
Unfortunately, both cases are associated with lots of manual data entry. But it is possible to smooth the edges and automate your customer import to Magento 2. Let’s see how.
How to import customers to Magento 2 and assign them to a customer group
As we’ve mentioned above, you need the Improved Import & Export Magento 2 extension to solve the issue. This module adds three columns to the Customers Main file:
- _customer_group_code
- _tax_class_name
- _tax_class_id
How does this improvement help import customers to Magento 2 and assign them to a customer group? Let’s see.
If there is no group_id attribute or the corresponding column is empty, it’s no longer a problem.
- If a customer group from the _customer_group_code column exists on your website, the Improved Import & Export module takes the _customer_group_code value and adds a customer to the corresponding customer group.
- If a customer group from the _customer_group_code column DOESN’T exist on your website, the module takes the _customer_group_code value and the _tax_class_name value and acts as follows:
- The Improved Import & Export extension creates a new customer group on the fly with a name from the _customer_group_code column if a tax rule name from the _tax_class_name column exists on your website.
- However, no new customer group is created if a tax rule with the same name as the one in the _tax_class_name column DOESN’T exist on your website. It happens because the extension doesn’t know to which tax class the customer group is related. In this case, it displays the following error: _tax_class_name in line X does not exist. It means that you need to create the corresponding tax rule on your Magento 2 website to address this issue.
- The Improved Import & Export extension creates a new customer group on the fly with a name from the _customer_group_code column if a tax rule name from the _tax_class_name column exists on your website.
- Alternatively, the Improved Import & Export extension can rely on the _tax_class_id attribute. If the class with the ID from the import table exists on your website, then a customer group is automatically created during the import process and customers are assigned to it. If no tax class ID on your website matches the one from the customer import file, no new customer group is created.
Note that the _tax_class_id attribute has higher priority over the _tax_class_name attribute. However, It’s enough to have at least one tax attribute (either _tax_class_id or _tax_class_name) on your Magento 2 website to create a customer group and assign customers to it automatically during the import process.
It is also worth mentioning that the group_id attribute has a higher priority over the _customer_group_code attribute. If their values are different, the Improved Import & Export extension will take the value from the group_id attribute to create a new customer group and assign customers to it upon import.
We hope this information will help you import customers to Magento 2 and assign them to a customer group faster than ever before!
In addition to the ability to import customers to Magento 2 and assign them to a customer group even if it doesn’t exist on your website, the Improved Import & Export Magento 2 extension lets you transfer all the core Magento 2 entities according to a cron-based schedule, using different file formats (such as CSV, XML, XLSX, and JSON) and sources (Dropbox, Google Drive, etc.). Furthermore, it is possible to apply mapping to third-party data to transfer information from any source straight to your e-commerce website. You can also run API-based import and export processes and move any entity to and from your Magento 2 website using Google Sheets. Follow this link to learn more about the extension:
Get Improved Import & Export Magento 2 Extension
Also, check our Magento 2 Cookbook for more useful tips.