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 to satisfy only basic data transfer demands, the Magento XML product import becomes questionable. However, there is still an opportunity to achieve this goal.
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 way for Magento 2 to import products from the XML feed. With its help, you can move all the necessary information to your e-commerce store without converting the update to CSV.
In the article below, we describe 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.
Although this article focusses on import, you will also learn how to establish the Magento export of products via XML. Since our extension supports all Magento 2 entities, it enables the Magento XML order export as well. See the general guidance below. Other useful tips for Magento 2 users are gathered in our Magento 2 Developer’s Cookbook.
How to import XML files using the default Magento 2 tools
There is only one way to import XML files to Magento 2 without using third-party modules. You need a tool that converts XML to CSV. Check this service or this one. Next, you should import a sample CSV file from Magento 2 and compare it with the converted one. If there are any inaccuracies in your CSV file, it is necessary to fix them. Otherwise, you won’t import the necessary data to Magento 2.
As for the import, ageneral workflow looks as follows:
Go to Admin -> System -> Import.
Select your entity type.
Choose an import behavior option: Add/Update, Replace, or Delete.
Select a CSV file to upload. Click “Check Data” to verify if the data is correct.
Make sure to find an article that covers your import case in our Guide List. You will learn to compose and edit a CSV table with the proper attributes Magento 2 requires for import:
How to import XML into Magento 2 without headaches
There is another option though – you can import products and other entities to Magento 2 via XML files with the help of theImproved Import and Export extension. No conversions are required!
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 to import XML files into Magento 2.
You will need these two components:
The latest version of the Improved Import and Export extension installed on your website;
An XML file you want to import.
No more no less. If you are reading this article you probably have an XML file, so let’s configure the extension.
Step 1: Create an import job
The Improved Import and Export extension operates with jobs. A 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 are available under System > Improved Import/Export > Import/Export Jobs of your Magento 2 administrator panel.
The first screen you see is a jobs grid. Here you can create, manage, and delete any import or export jobs. To create a new job click the ‘Add New Job’ button in the upper-right corner of the screen.
Step 2: Configure general job settings
This article covers only the basic aspects of an import job. If you want more thorough instructions on how to work with the extension, read the Improved Import and Export manual.
First, you are suggested to name the job, set the schedule if necessary, decide whether you want to reindex the store after the import is done, get rid of possible URL conflicts (read more about the error), etc.
Once done with the General Settings, specify the entity you want to import. Regarding the Magento XML product import, choose Products from the Entity dropdown.
In addition to default entities Magento 2 offers, the extension allows you to import such entities as CMS pages, cart price rules, categories, and others.
After an import entity is selected you can specify separators for the table you are importing. This can be helpful for CSV tables of particular formatting. However, you can skip this step for an XML table.
On the Import Source tab, specify XML as your Import File Type. Next, choose the source of your XML file. 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 the path to the XML file is specified, hit the “Validate file” button. The extension will scan the file for unsupported attributes and values. If everything is fine, the rest of the job settings appear.
Step 3: XSLT transformation
By default, the extension supports 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 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 get it from FireBear Studio GitHub.
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 XSL file can be found at FireBear Studio GitHub.
To apply the XSLT template, scroll down to the XSLT Configuration section of the new import job screen. Here, enable the XSLT transformation and paste the XSLT template. Once done, hit the “Test XSLT 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. Send us a message – we can compose an XSLT template for you!
Step 4: Run the import job
The only thing you are left to do is to click the 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 templates – contact the FireBear support team. We will help you create a proper XSLT template and import any XML table into your store.
Magento 2 XML export of products, orders, customers, and other entities
As for the export process, it is even more straightforward. With the Improved Import & Export extension, the Magento XML order export, for instance, is reduced to a few clicks. So is the Magento export of products via XML. Let’s see.
With the Improved Import & Export extension, you can apply multiple useful features to the order export output. Let’s see what advantages our module brings into the game:
Proceed to System > Improved Import/Export > Export jobs. Click the “Add New Job” button to create a new export job.
In the General Settings, specify the job name and set the job schedule if you want to run the export process automatically.
In the Export settings, select an entity you want to export. Let’s choose Order.
In the Export Behavior, you select the file format – XML.
In the Export Source section, select the export source for your Magento 2 export of orders: File, Google Sheets, Dropbox, FTP, URL, etc. Next, specify a path to the XML output. Files are created automatically and can be downloaded from the export job screen after the export is complete.
Also, you may need to map attributes and apply additional filters to modify Magento’s order export output. You can read more about these features in the Improved Import and Export Extension Manual.
Finish the configuration and run the export process.
That’s it! Now, you can freely export orders, products, and other entities from Magento 2 with the help of XML files.
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.
Final Words
The Magento 2 import and export of XML files is not a big deal if you use the Improved Import & Export extension. The module not only supports this file format for data transfers but also introduces the ability to apply XSLT transformation templates to import any XML files to your website. No matter you deal with the Magento XML product import or Magento XML order export – you now know the best way to fulfill your data transfer needs. Follow this link and contact our support regarding Magento 2 XML import and export processes.