We all know that Magento 2 supports CSV import/export by default, but what if you need to transfer data via XML files? Although the default Magento 2 data import capabilities are enough for satisfying only basic data transfer demands, there is an opportunity to achieve the goal mentioned above.
Since the system supports only the CSV standard, you need to convert your XML files to the supported file type. If you don’t want to do that, meet the Improved Import & Export Magento 2 extension. This module offers a more user-friendly solution for importing XML to Magento 2. With its help, you can move all the necessary information to your e-commerce store without converting it to CSV.
In the article below, we provide the description of how to import XML files using the default Magento 2 tools. Besides, you will find a step-by-step guide to Magento 2 XML import and export. More useful tips for Magento 2 users are gathered in our Magento 2 Developer’s Cookbook.
Table of contents
- 1 How to import XML files using the default Magento 2 tools
- 2 How to import XML into Magento 2
- 3 Magento 2 XML Import & Export FAQ
- 3.1 How to import and export XML files to Magento 2 automatically?
- 3.2 How to import XML files with third-party attributes to Magento 2?
- 3.3 How to import and export data to Magento 2 via ODS files?
- 3.4 How to import and export data to Magento 2 via XLSX files?
- 3.5 How to import and export data to Magento 2 via JSON files?
- 3.6 How to import data to Magento 2 via compressed files?
- 3.7 How to import data to Magento 2 from Google Sheets?
- 3.8 How to import and export XML files to Magento 2 from Dropbox?
- 3.9 How to import and export XML files to Magento 2 from Google Drive?
- 3.10 How to import and export data to Magento 2 via API?
How to import XML files using the default Magento 2 tools
There is only one way to achieve this goal without using third-party modules. You need a tool that converts XML to CSV. Check
Make sure to read the Guide List we have composed for you on how to properly compose and edit a CSV table and what attributes Magento 2 requires for import:
There is another option though – you can import XML with the help of the Improved Import and Export extension that we (FireBear Studio) have developed and keep updating with new features.
The latest release of the extension added XSLT transformation, to further complement XML file import. XSLT for Magento 2 allows transforming XML files to the formatting accepted by Magento 2. Read more about XSLT transformation.
But first things first. Let’s talk about how can one import XML files into a Magento 2.
How to import XML into Magento 2
To import XML files into Magento 2 you will need two things:
- Installed Improved Import and Export extension
- And XML file you want to import
No more no less. If you are reading this article you probably have an XML file, so let’ focus on how to setup and configure the extension.
Step 1: create an import job
Import Import and Export extension operates with jobs. Job is an automated ‘rule’ that dictates the extension when and on which conditions a particular file can be imported.
Both import and export jobs for Magento 2 can be located under System > Improved Import/Export > Import/Export Jobs of your Magento 2 administrator panel.
The first screen you see is the jobs grid. Here you can create, manage and delete any import or export jobs. To create a new job click ‘Add New Job’ button in the upper-right corner of the screen.
Step 2: configure general job settings
In this article we will only cover the basic aspects of configuring the job. If you want more thorough instructions on how to work with the extension – read Improved Import and Export manual.
First you are suggested to name the job, setup the schedule if any, and decide whether you want to reindex the store after the import is done and get rid of possible URL conflicts with Generate Unique Url if Duplicate setting (read more about the error).
Once done with the General Settings you are suggested to specify the entity you want to import. In addition to default entities Magento 2 offers, the extension allows you to import such entities as: CMS pages, cart price rules, categories and other.
After an import entity is selected you can specify separators for the table you are importing. This can be helpful as Magento 2 can only accept CSV tables of particular formatting. However, as we are import XML table we will pass this step.
Now you are suggested to specify the source you will be importing from. Here Improved Import and Export offers quite a number. You can import files from Google Sheets, FTP/SFTP, Dropbox, direct URL or from the local file.
When you specified the path to the XML file you will be importing you will need to hit ‘Validate file’ button. The extension will scan the file to find the imported entities. If everything is fine the rest of the job settings will appear.
Step 3: XSLT transformation
By default the extension support XML tables of the following formatting:
- XML 1.0
- encoding: UTF-8
- field separator: space
- first row: column names
- top-level root name: Items
- XML record name: item
However, with XSLT transformation you can pretty much ignore these, as the XSLT language allows you to transform the XML table into pretty much anything you want.
To give you an example, let’s import a custom XML table. This very table uses custom names for product attributes and custom formatting. You can
Now, to transform this XML into the appropriate format we will need to use an XSLT template. You can think of the template as a set of instructions for the XML on how to behave and how to look. The same
To apply the XSLT template, scroll down to the XSLT Configuration section of the new import job screen. Here you will need to enable the XSLT transformation and paste the XSLT template. Once done hit the ‘Test XSL Template’ button. The extension will do the necessary tests.
If you are not sure how to compose an XSLT template or require any assistance – feel free to contact the FireBear support team:
We can compose XSLT template for you!
Now, let’s move to the final step of XML file import.
Step 4: run the import job
That’s pretty much it. The only thing you are left to do is to click big orange ‘Save & Run’ button. The extension will import the XML file with proper formatting.
Remember, if you require assistance with your custom XML files and composing XSLT template – contact the FireBear support team. We will help you compose a proper XSLT template and make sure the XML table is imported into your store.
Magento 2 XML Import & Export FAQ
Let’s take a look at other nuances of importing and exporting XML files in Magento 2 with the help of the Improved Import & Export Magento 2 extension.
How to import and export XML files to Magento 2 automatically?
If you need to import or export XML files between Magento 2 and third-parties or other Magento 2 websites on a regular basis, use the Improved Import & Export extension. The module uses a cron scheduler for automating data transfers. As a result, you get the ability to import and export XML files between Magento 2 and external destinations automatically. Create a schedule of updates and let the module do everything for you.
How to import XML files with third-party attributes to Magento 2?
While Magento 2 blocks the import of third-party data that doesn’t follow its requirements, the Improved Import & Export extension lets you do that. You only need to create a mapping scheme where you match third-party attributes and values to the corresponding ones used within the system. As a result, any external data is easily adapted to the native standards of your e-commerce website. Note that you can also apply mapping to export processes to generate the output your partners require, freely transferring XML files to and from Magento 2.
How to import and export data to Magento 2 via ODS files?
In addition to XML, Improved Import & Export lets you move data via ODS files. You no longer need to convert them to CSV to fit the Magento 2 requirements. You can also export data using this file format.
How to import and export data to Magento 2 via XLSX files?
In addition to XML, Improved Import & Export lets you move data via XLSX files. You no longer need to convert them to CSV to fit the Magento 2 requirements. You can also export data using this file format.
How to import and export data to Magento 2 via JSON files?
If data is stored in a JSON file, you no longer need to convert it to a CSV file to fit the Magento 2 requirements. With the Improved Import & Export Magento 2 extension, you can import JSON files to your ecommerce website without any necessity to run the conversion, just like in the case of XML. You can also export data using this file format.
How to import data to Magento 2 via compressed files?
If your XML files are compressed, you can also transfer them to Magento 2 with the help of the Improved Import & Export extension. However, there is a requirement to follow: your file archive should be in a ZIP or TAR format. In addition to XML, our module also supports compressed CSV, JSON, ODS, and XLSX files.
How to import data to Magento 2 from Google Sheets?
If data is stored in Google Sheets, it is no longer a problem. There is no need to export it from the service and then transfer the output to Magento 2. Neither XML nor CSV files are required! The Improved Import & Export lets you move the corresponding information straight from Google Sheets to your e-commerce website after you specify the address of the corresponding data table.
How to import and export XML files to Magento 2 from Dropbox?
In addition to Google Sheets, the Improved Import & Export module lets you transfer data to Magento 2 from Dropbox. This time, you can upload XML files there and import them to Magento 2. Besides, it is possible to work with CSV, JSON, ODS, or XLSX. If it is a compressed file, it should be in a ZIP or TAR format. You can use this file storage to export XML files.
How to import and export XML files to Magento 2 from Google Drive?
In addition to Google Sheets and Dropbox, the Improved Import & Export module lets you leverage Google Drive to transfer XML files to Magento 2. Besides, you can use this file storage for CSV, JSON, ODS, and XLSX files that can be compressed in a ZIP or TAR format. You can use this file storage to export XML files.
How to import and export data to Magento 2 via API?
If you want to avoid using XML files or files of other standards, the Improved Import & Export Magento 2 extension provides the ability to create API connections. As a result, it is possible to transfer information between Magento 2 and any external system in a bi-directional API connection. The module’s import/export jobs provide an interface where you can specify the parameters necessary to sync the two systems. As for transferring unsupported attributes, the plugin lets you leverage its mapping functionality for API connections.