How can I Import Products with Special Characters into Magento 2?
Recently a client approached us to load a large number of products onto their Magento 2 website. The client is involved in the aftermarket automotive parts trade and they supply kits for a wide range of passenger and commercial vehicles. This results in a BIG product catalogue with all the garnishings especially dollops of complicated configurabes!
I knew a problem product load was on the cards, so I asked for an early look at their data. When I received the data dump from their system, I found that many of their product names and descriptions contained special characters. This was especially bad in the data for the product dimensions as these dimensions contain special characters.
What Are Special Characters in a Magento Product Import Sheet?
When one thinks of the words 'special character', one might think of a special type of person that has more than just the normal needs. But the special character I'm talking about is used in /on computers. If you just look down at your keyboard in front of you you should see these characters just above the alphanumeric key-set as they are on all standard computer keyboards. Also known as the 'ALT-Keyboard-Sequence' eg. !@#$%^&*()
What Issues do Special Characters Cause when importing Magento 2 Products?
The thing about these products is that they contain ‘special characters’ within the data, as the products I’m currently creating the .CSV import sheet contain ‘dimensions’ as you can see in the image below.
I know from experience, that when you use special characters in names or skus, one of two outcomes are produced:
The Magento product import process breaks as you run the import.
Magento simply ignores some of the product details even though you receive a message telling you the import was successfully done.
To my surprise I found the products missing when I went and looked at the data and went back to my .CSV import sheet. I saw it had special characters in the ‘name’ column which were ‘??’, and the result in the Magento 2 Admin backend was that none of the names were created for any product on that import sheet. So we learn once again by failing.
I will now explain how I got these ‘dimensions’ using a .CSV import sheet…
Firstly, you need to create a product attribute by going
- Stores -> Attributes -> Product
- Then click on -> Add New Attribute
As I said early, the problem we had was that we needed to get the ‘Dimensions’ in the product data which contain ‘special characters’ without breaking the products.
So... I have a ‘Default Label’ labeled -> ‘Dimensions’.
Next, you will see the ‘Catalog input Type for the Store’ and this is the actual key to get them in, just set it to ‘Text Editor’ and ‘Values Required’ set to ‘No’. Once you have labeled and named the new product attribute click on -> ‘Save Attribute’
After you have saved the new attribute, you are now able to add the ‘special character’ data you want to import. Simply, create the column heading for ‘dimensions’ and add the ‘special character’ data in the dimensions column on the .CSV, as you will see in the image below I have added it using HTML <p> tags !@#$%^&*(). Note that the <p> tags are not compulsory and data should still import fine without the HTML tags.
Download the .CSV import sheet and then go to the Magento 2 Admin backend to do the import.
- System -> Data Transfer -> Import
- Choose the .csv file and click on -> ‘Check Data’
- Once the file is valid and contains no errors, and is ready click on -> ‘Import’
- Now you go to admin sidebar to Catalog -> Products
We can now see the file has been imported successfully in the backend and we can now look at the product and see that these ‘special characters’ have been imported flawlessly.