How to import and export Magento 2 MSI and how it works. Magento 2 multi source inventory (MSI) import guide and manual

- E-Commerce, Magento 2

Magento version 2.3 came out with the long awaited Multi-Source Inventory (MSI) support. The feature is available right after installing the MSI extension.
In this blog post you will learn how to import and export all Magento 2 MSI entities: sources and quantity of the products per source

What is Magento 2.3 MSI

Magento 2 MSI – is a multi-source inventory management system. This system allows you to allocate product stock per warehouse, decide from which warehouse the product should be shipped to the customer. Basically, if you are using multiple warehouses to store your products – this feature is a must for your Magento 2 store.

Before Magento 2.3 release the MSI functionality could have been added to your store using third-party extensions. We have already discussed such third party extensions in the article here. If you are looking for the full picture on Magento 2 MSI, or want to replace the native MSI functionality you may actually want to read it.

Read how to work with MSI functionality

In this article however we will talk about how to import and export Magento 2 MSI entities, namely sources and product quantity per source.

Installing MSI Add-On for Improved Import and Export

NOTE: Before installing MSI Add-On make sure you have installed Improved Import and Export extension.

  1. Navigate to your store root folder in the SSH console of your server:

  2. Install MSI Add-On by running command:

  3. Enable MSI Add-On by running:

  4. Deploy content and flush store cache, log out from the backend and log in again. Run:


    and:

Congratulations, you have installed MSI Add-On for Improved Import and Export extension.

What do you need to import/export MSI entities

To import and export MSI sources and product quantity you will require Improved Import and Export extension with MSI Add-On installed. Improved Import and Export is a full-featured Magento 2 extension operational from both administrator panel and command line.

The extension covers almost all Magento 2 entities import and export and comes with the following features:

  • Import and export of products, categories, CMS blocks and pages, orders, cart price rules, customers, product attributes, advanced pricing.
  • Import and export of all Magento 2 B2B entities: companies, shared catalogs, requisition lists, quotes and negotiable quotes.
  • Support multiple file formats including CSV, XML (with XSLT templates), Excel XLSX, OpenOffice ODS, Json.
  • Support of Google Sheets – import CSV files by pasting a Google Sheet links.
  • Support of REST and SOAP API connections to different software.
  • Price adjustments.
  • Category mapping.
  • Custom logic and many more. Read full feature list at the extension product page.

That’s pretty much it, you only need to have Improved Import and Export extension installed. The extension comes with explicit user manual, sample files and extensive guides on every entity. Additionally, Firebear team composed sample Google Sheet Master Table and B2B Master table for you with every attribute described and sample values assigned.

Use all the information you can to master import and export procedures of your store and create required integrations with CRM, ERP or supplier services.

Table formatting of MSI entities

There are two MSI entities available for import and export: Stock Sources and Stock Sources Qty.

As you can see, these entities are pretty simple and, if you have ever worked with MSI functionality, should be easy to get into. Anyways, before you proceed we advise reading through the attributes of both entities to understand which values required and can be used for different settings.

Stock Sources MSI table

Stock Sources are the warehouses you create at Stores > Inventory > Sources.

Here you can add new Magento 2 Sources. The required attributes include:

  • Name – the name of the warehouse;
  • Code – the code of the warehouse used for internal identification purposes and serves as a reference when assigning product quantity;
  • Country – the country of the warehouse location;
  • Postcode – the postcode of the warehouse region.

The rest of the attributes are optional. When creating warehouses using the import procedure make sure to at least provide information for these attributes, otherwise your Magento 2 store won’t be able to create a warehouse.

Having explored warehouse creation from the administrator panel gives a better understanding of all the attributes in the import and export tables. Before proceeding to compose an import table or gathering data for it, make sure to experience manual warehouse creation.

Below you will find all Stock Source attributes available for import and export. For reference we suggest opening an MSI Stock Sources sample table in a separate tab of your browser.

Attribute name    Reference Values Value example
source_code Code of the warehouse. Is used for identification purposes. Can be up to 64 Latin characters in length, without spaces, can contain “-“, “_”. my_warehouse
name Name of the source Can be any value My First Warehouse
enabled Defines if the source is enabled 1 – enabled

0 – disabled

1
description Description of the source Can be any value This is my first warehouse
latitude Latitude of the source location Can only be geographic latitude value 123.12
longitude Longitude of the source location Can only be geographic longitude value 321.32
country_id ID of the Country of the source Address Data Can be only country code ID of Magento variant of ISO 3166-1 AT
region_id ID of the Region of the source Address Data Can be only Region code ID of Magento region codes 95
region Region of the source Address Data Can be any value – text field. Doesn’t work with ID. Moscovia
city City of the source Address Data Can be any value New York
street Street of the source Address Data Can be any value Street st.
postcode Postcode of the source Address Data Can contain only numerals 12345
contact_name Contact Name of the source Contact Info Can be any value John Doe
email Contact Email of the source Contact Info Can be only email value john@doe.com
phone Phone of the source Contact Info Phone number +123123123
fax Fax of the source Contact Info Fax number +123123123
use_default_carrier_config System attribute of the source with no particular use case in setting up a new source
carrier_links System attribute of the source with no particular use case in setting up a new source

NOTE: When creating Stock Sources using import jobs, make sure to provide information for the attributes: name, source_code, country_id, postcode. These attributes are required by Magento 2 system to create new warehouses. Without them a warehouse cannot be created.

Stock Sources Qty MSI table

Stock Sources quantity is applied at the product level once the warehouses are assigned to stocks at Stores > Inventory > Stocks. To check the quantity per warehouse navigate to the product of interest.

At the screenshot above you can see that we have two warehouses new-warehouse and old-warehouse. Both are assigned to a single product, and this very product has stock in both warehouses. When managing order shipping you will be given an opportunity to decide from which warehouse you want to send the item.

Below you will find all Stock Sources Qty attributes available for import and export. For reference we suggest opening an MSI Stock Sources sample table in a separate tab of your browser.

Attribute name    Reference Values Value example
source_code Code of the warehouse. Is used for identification purposes. Make sure to specify the exact code value. The code is used to tie product stock to source. my_warehouse
sku SKU of the product which stock is tied to a particular source (warehouse) Can be up to 64 Latin characters in length, without spaces, can contain “-“, “_” TST-01
status Source Item Status. Defines if the products in a particular source are in- or out-of-stock. 1 – in stock

0 – out of stock

1
quantity Quantity of products in a particular stock (warehouse) Can only contain numerals 123

NOTE: if your product belongs to several stock sources (warehouses) for every warehouse in the import table you need to have a dedicated row. For example:

As you can see at the screenshot above we have three warehouses:

  • new-warehouse
  • old-warehouse
  • default

And four products:

  • 24-MB01
  • 24-MB02
  • 24-MB04
  • 24-MB06

All these products belong to all three warehouses. That’s why for every warehouse every product has a separate row. When importing such files, the product quantities per warehouse are imported in order they appear in the file.

How MSI source import/export works

Below you will find an example of how to export MSI source from Magento 2 and how to import it back to Magento 2 with a new source included. The screenshots are taken from the Improved Import and Export extension which is different from native Magento 2 import/export tool.

Please refer to Improved Import and Export extension manual for explicit instructions on how to use every feature of the extension. The sample below is a sample to give you an idea of how Improved Import works. It doesn’t cover every feature of the extension and doesn’t provide step by step instructions.

For reference you can use Firebear demo store in a separate browser tab.

Exporting Magento 2 stock sources

Navigate to System > Improved Import/Export > Export jobs. At the export jobs grid you will see all already created jobs.

To create a new export job click ‘Add New Job’ button. You will be redirected to the job settings screen.

In the General Settings specify the export job name and set a required frequency if you plan scheduling the job to run automatically. Scroll down to the Export Settings section.

Select ‘Stock Sources’ from the Entity drop-down and proceed to the Export Behavior.

Select required file format from the File Format drop-down and apply necessary mapping if required. Scroll down to specify the source where you want to export the stock sources.

Select the source you want to export to from the Export Source drop-down. Specify the path to the file with the file name you want to create (don’t forget the file format). If required you can also add a current timestamp to the file name automatically using HTML date format preferred.

That’s it. You can now click big orange ‘Save & Run’ button at the top right corner of the screen to execute the export job and get a file with Magento 2 stock sources already created at your store.

Importing Magento 2 stock sources

First, let’s add another stock source to the file we have just exported. If you have been exporting stock sources to the CSV format the best way to edit it is to use Google Sheets. Excel and OpenOffice have tendencies of adjusting to CSV files so it is better to use Google Sheets.

Editing import table

The export file will look something like this if you love colors:

Sample Google Sheet stock source table

Looking at the columns A source_code and B name we can see that we have two sources:

  • Default Source with code default
  • Old Warehouse with code old-warehouse

To add a new source you will need to another row with the source information that you have. Let’s complete row 4 with the information we want. Say, we have:

  • New Warehouse (name warehouse)
  • In US, Texas, postcode 12345 (address)
  • With contact point being John Doe, phone +123123123, email john@doe.com (contact)

Now we need to get this information into the table we have. Using the attribute table from this blog post you can find all the required attributes to fill in this information like this:

The only thing we had to come up with was the source_code for the new warehouse. Think of it the same as product SKU, this is a unique identifier of the stock source. All other information in the row 4 is the same we had written for the warehouse.

Let’s now import this very table we have edited.

Importing edited import table

To create a new import job proceed to System > Improved Import/Export > Import jobs. And click ‘Add New Job’ at the import job grid.

In the general settings of the import job specify the name and schedule if you want to run the job automatically on the regular basis.

Scroll down to the Import Settings and select the entity you want to import ‘Stock Sources’

From the Entity drop-down you can select the entity you want to import. When finished scroll down for Import Behavior section.

Here you decide how do you want the import job to proceed. Currently there are three scenarios:

  • Add/Update – new entities are added and existing entities are updated
  • Replace – existing entities are replaced if the ID matches to the entities in the imported table
  • Delete – entities from the imported table are deleted from the store

For this article purposes we go with ‘Add/Update’, as we want to add another stock source to the Magento 2 store. Scroll down to the Import Source section.

Considering you have been editing the table in the Google Sheets, you can just share this table and paste its link to the import source. The extension will get the file and import it to your store.
Import Sources include:

  • File upload
  • FTP/SFTP
  • Dropbox
  • Direct URL
  • Rest and Soap APIs
  • Google Sheets

Once the link to the file pasted – click ‘Validate file’ button and after the validation is complete click ‘Save & Run’ button at the top right corner of the screen.

That’s it. Once the import is complete you can check your stock sources for the new source.

This is a simple case of running both import and export jobs. Improved Import and Export extension many more settings and flexibility. To get full list of features visit the extension product page or read Improved Import and Export manual and Guide List where we give explicit instructions on how to import any entity to your Magento 2.