How to Import Product CSV in Magento2 Enterprise Edition

How to Import Product CSV in Magento2 Enterprise Edition

July 18, 2018 / Eternal Team

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 setup Magento Commerce (Enterprise Edition) in your local system and import product listing from a given CSV file.

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.0/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.

Related Blogs

blog

August 8, 2018

Magento Server Automated snapshots Backup for EC2...

Sharing is caring!

Magento itself provides inbuilt backup facility for its entire backup of application and database.Y…

blog

July 26, 2018

Best Magneto Architecture on AWS Server...

Sharing is caring!

Magento provides two distinct platforms: Magento Open Source (previously Magento Community…

blog

June 25, 2018

CenPOS plugin for Magento 2...

Sharing is caring!

CenPOS is all in one platform for the e-commerce industry. CenPOS provides simple, secure and flexible…

Want to start a project?

It’s simple.

Contact us