How to Import Product CSV in Magento2 Enterprise Edition

How to Import Product CSV in Magento2 Enterprise Edition

July 18, 2018 / Nirav Shah

How to Import Product CSV in Magento2 Enterprise Edition

Magento has emerged as a very important tool for many categories of business owners. It is quite powerful and helpful in helping a business owner set his/her personal e-commerce store. It has also grown a community and an ecosystem of its own.

Magento is available as:

  1. Community Edition – Can be installed on self-hosted server
  2. Enterprise Edition – Hosted by expert Magento team

This blog post contains all the information that you need to set up Magento Commerce (Enterprise Edition) in your local system and import product listing from a given CSV file.

Steps to import products from ERP to Magento

Basically we need to follow below steps to import products from erp to magento in enterprise edition.

  1. Setup Enterprise edition in local system
  2. Download csv to local server from ftp server and move original csv it to Archive folder
  3. Authenticate REST API through Token authentication
  4. Get list of products using API
  5. Add product to magento API
  6. Update product in magento using API

1. Setup Enterprise edition in local system

We need to follow below steps to setup enterprise edition in our local system.

(a) Install all required packages and tools first.

https://devdocs.magento.com/guides/v2.2/cloud/before/before-workspace-magento-prereqs.html

(b) Add SSH key

Using below command, you can create new ssh key.

ssh-keygen -t rsa

You can also define file where you want to save key.

(c) Install Magento CLI

curl -sS https://accounts.magento.cloud/cli/installer | php

(d) Add ssh key to CLI

magento-cloud ssh-key:add ~/.ssh/id_rsa.pub

(e) Clone and branch the project

To clone the project’s master environment to your local:

Login to Magento Cloud CLI:

magento-cloud login

List your projects:

magento-cloud project:list

Clone the project:

magento-cloud project:get

2. Download csv to local server from ftp server and move csv it to Archive folder

We have used Laravel for Import process. Below is the laravel script to download csv from ftp server and move that csv to archive then.

code

3. Authenticate REST API through Token authentication

There are 3 types of authentication we can use:

  • i) Token-based authentication
  • ii) Session-based authentication
  • iii) OAuth-based authentication

We have used here Token based authentication.

The token allows Magento to verify that the caller is authorized to access a system resource. To get a token, you must specify the user’s username and password in the request. You need to use following script to create token in PHP.

Note :- make sure username is admin user with proper resources should be assigned.

code

This token must be specified in the authorization header of every api call that requires admin permissions, like api call to get the list of products, add new product, update existing product or delete product.

4. Get list of products using API

For getting the list of products from magento we can use following API.

code

You will have to pass token in header here.

If you want to get all the products then use “searchCriteria=0” in request url else if you want to filter product by sku or category, then you will have to pass proper searchCriteria. For that you can refer: https://devdocs.magento.com/guides/v2.3/rest/performing-searches.html

5. Add product to magento using API

For adding product you can use this api url:

{your_magento_host}/rest/{storeViewId}/V1/products

code

If we want to add product in any specific store view, we need to pass in url.
{storeViewId} can be all or default or any store view code.

6. Update product in magento using API

To update any product, you need to use the same api url.

code

In data array we will pass all required data which we want to update.

Also Read Magento2 on AWS – Everything You Should Know About

Talk to AWS Certified Consultant

    Spread Love By Sharing:

    Let’s Talk About Your Needed AWS Infrastructure Management Services

    Have queries about your project idea or concept? Please drop in your project details to discuss with our AWS Global Cloud Infrastructure service specialists and consultants.

    • Swift Hiring and Onboarding
    • Experienced and Trained AWS Team
    • Quality Consulting and Programming
    Let’s Connect and Discuss Your Project