How to Run Product Import in Magento 2 from CLI

- Fire development, Magento 2

Magento 2 Development; Magento 2 tutorial

If you want to optimize your daily routine related to Magento 2 product import, you’ve come to the right place. Below, we shed light on several data transfer optimizations that will help you save tons of time spent on daily chores. Many merchants look for tips on how to import products to Magento 2 using the command line interface or an alternative way to achieve the same goal. Below, you will find the answer. The following article is based on the StackExchange question by Massimo Camoni and the answer by Khoa TruongDinh. However, it extends the solution provided in the discussion. So, let’s see how to run Magento 2 product import via CLI. Also, you will find out what commands to use to export products from Magento 2.

'

The StackExchange Approach

According to Khoa TruongDinh, you cannot import products to Magento 2 using CLI in the most efficient way. Instead, he proposes to set up the Scheduled Import for the Commerce version under System > Data Transfer > Scheduled Imports/Exports. You can read more about the feature here: Data Scheduled Import Export.

The Improved Import Approach

If you’re using the Open Source version, you should rely on third-party modules, such as the Improved Import & Export Magento 2 extension.

Our module fully supports cron enabling you to create any custom schedule of updates. There is no need to use CLI commands since everything can be configured within the extension’s backend in the most user-friendly manner.

You need to know the standard cron syntax to create a custom update schedule. Alternatively, it is possible to select one of the predefined time intervals to run the update. Besides, you can still run product import asynchronously in manual mode.

General extension settings

For further information about the extension, follow this link:

Download/Buy Improved Import & Export Magento 2 Extension

How to Run Product Import in Magento 2 from CLI

The default import tools of Magento 2 don’t let you use CLI. As you might have already guessed, Improved Import & Export solves this problem. With the extension, you can enable, disable, or start export processes from the Magento 2 CLI interface. Run the following commands in the Magento 2 root folder:

Also, check these CLI export commands:

Note that you have to create corresponding jobs for both import and export processes.

We hope the article was useful. For other Magento 2 tips, check our Cookbook.

Magento 2 CLI Import & Export FAQ

How to disable an import job via CLI in Magento 2?

Use the following command to disable an import job in Magento 2 via CLI:
php -f bin/magento import:job:COMMAND JOB_ID
import:job:disable

How to enable an import job via CLI in Magento 2?

Use the following command to enable an import job in Magento 2 via CLI:
php -f bin/magento import:job:COMMAND JOB_ID
import:job:enable

How to run an import job via CLI in Magento 2?

Use the following command to run an import job in Magento 2 via CLI:
php -f bin/magento import:job:COMMAND JOB_ID
import:job:run

How to disable an export job via CLI in Magento 2?

Use the following command to disable an export job in Magento 2 via CLI:
php -f bin/magento export:job:COMMAND JOB_ID
export:job:disable

How to enable an export job via CLI in Magento 2?

Use the following command to enable an export job in Magento 2 via CLI:
php -f bin/magento export:job:COMMAND JOB_ID
export:job:enable

How to run an export job via CLI in Magento 2?

Use the following command to run an export job in Magento 2 via CLI:
php -f bin/magento export:job:COMMAND JOB_ID
export:job:run

How to automate import and export processes in Magento 2?

Use the Improved Import & Export Magento 2 extension to automate both import and export processes in Magento 2. The module provides a cron scheduler where you can configure the frequency of automated data transfers.

How to import and export data with third-party attributes in Magento 2?

The Improved Import & Export Magento 2 extension provides a user-friendly mapping interface, where you can match all unsupported attributes to ones used in Magento 2. As a result, any third-party data is automatically transformed during import processes and effortlessly transferred into Magento 2. Furthermore, the same tool is suitable for export, working in the opposite direction. In this case, you show what data to use to replace the default Magento 2 attributes, generating the output your partners require.

'