Ms.imports

Import CSV file for bulk uploading of products in your store

Fields

name
Type: string

Read Only: No

Required: No
"name of csv file uploaded by client"
pathPath where CSV file is stored.
sizesize of CSV file in Bytes
typeit describes the type of CSV file i.e (text/csv) .If type of file does not matches,file will not be uploaded
status
Type: string

Read Only: No

Required: No
It describes the status of processing of CSV file . Status will be "uploaded" by default when we upload  a CSV. It will keep on changing till the CSV processing is completed.
 Various stages of CSV are decided by its status : -
  • UPLOADED : Initially when we upload a CSV,its status is "uploaded",its processing doesn't starts till.
  • PENDING_PARSE : file is under parsing phase,it will create new categories,collections,brands mentioned in products in file & check any syntax,manual or CSV format error in this phase. 
  • PARSED : file will separate ROWS and RECORDS from file and save in ms.imports entity.
  • RUNNING : records start converting into products in batch of 10 at a time and insert products in ms.products entity
  • COMPLETED : CSV file is completed with records having "processed","unprocessed" or "error" status which we will describe soon.
uploaded_by
Type: string

Read Only: No

Required: No
It describes the email ID of the person who uploaded the CSV file.
Rows
Type: array

Read Only: No

Required: No
It describes the information about each row of the CSV file uploaded 
It contains various variables :-
  • _id : each row has its unique id
  • line_number : it decribes the serial number of row.
  • record_id : it describes the id of record to which this row belongs.one record may conatin more than one rows 
  • row : it contains all the data mentioned in that particular row
  • status : it describes the status of that particular row.initially it is "unprocessed" & after processing its status changed to "processed". 
Records
Type: array

Read Only: No

Required: No
It describes the information about each product/record of the CSV file uploaded.  
It contains various variables :-
  • _id : each record has its unique id 
  • record : it contains all the data mentioned in that particular record
  • status : it describes the status of that particular record.initially it is "unprocessed" & after processing its status changed to "processed" or unprocessed with some errors in error field.

Related Resources

ms.imports
It contains the list of CSV files uploaded in the store with "uploaded by" and its various status
ms.products
This contains the list of all products.products are imported into this entity
ms.delivery_pincodes
if we want to import delivery_pincodes into a store.we will import CSV file into this entity .
Deleting entry of particular CSV DELETE /entity/ms.imports/{#_id}

It will delete the entry of particular CSV from ms.imports entity.

Example

Delete single Import
DELETE /entity/ms.imports/53b256e9b3af14aa15e451a5

Example Request Json

{
    "entity":"ms.imports",
    "recordId":"53b256e9b3af14aa15e451a5"
}

Example Response Json

{
    "data":"Deleted Successfully"
}

Query Parameters

CodeMessage
_IdUnique Identifier of the import to be deleted
Start Parsing of CSV file GET entity/ms.products/_/parseimport

This command will get the data of requested Id from ms.imports & start parsing the CSV file uploaded by user.it will insert new categories,brands,collections entered in the CSV into the store & will convert CSV data into RECORDS and save this data in ms.imports entity after parsing is finished. Logically it will Analyse CSV file into logical syntactic components called PRODUCTS.  

Example

Parse Import
GET

Example Request Json

data = {
                    entityName: ms.products,
                    executeHooks: true,                  
                    data: {
                        _id: "55bef9159cad703e28e43b5e"
                    }                    
                }

Example Response Json

{ data: 'parsed',
  status: 200,
  messages: 
   [ { name: 'ms.entity.products.parseImport',
       level: 'success',
        } ] }

Message

CodeMessage
200success
406With specific error message

Query Parameters

CodeMessage
entityNameName of the entity on which file is imported.It can be any entity which support "import" functionality.
data._idUnique Identifier of the import to be updated
Start importing products into store after parsing GET entity/ms.products/_/startImport

This command will get the data from requested ID & get records  in batch of 10 from ms.imports entity and will start putting products in ms.products and updating status of records after each batch process. Initially all records have "unprocessed" status. After processing their status are updated to "processed" or "unprocessed with error"
After all products are processed ,it will change the status of CSV file from running to "completed"

Example

Start import
GET

Example Request Json

data = {
                    entityName: ms.products,                   
                    data: {
                        _id: "55bef9159cad703e28e43b5e"
                    }                   
                }

Example Response Json

{ data: true,
  status: 200,
  messages: 
   [ { name: 'ms.entity.products.startImport',
       level: 'success',
        } ] }

Message

CodeMessage
200success
406With specific error message

Query Parameters

CodeMessage
entityNameName of the entity on which file is imported.It can be any entity which support "import" functionality.
data._idUnique Identifier of the import to be updated
Import a CSV file POST /entity/ms.imports/

When CSV is  imported,file will get save on server and on submit, file data along with unique ID and import ID will get save in ms.imports entity with status "UPLOADED"

Example

Uploading a csv
POST

Example Request Json

entity: "ms.products",
  file: {
name: "try1.csv",
path: "tmp/56659513f39863bf67276b0a/try1.csv",
size: 365,
type: "text/csv"
uploadType: "tmp"
},
status: "uploaded",
uploaded_by: "mmittal265@manusis.com"

Example Response Json

_id: "566695a8dc95054a27a0b75c"

Query Parameters

CodeMessage
entityName of the entity where import will be performed
nameName of the CSV file with '.csv' extension.
pathPath where CSV file is stored .
sizesize of CSV file in Bytes
typeIt describes the type of CSV file i.e (text/csv) .If type of file does not matches,file will not be uploaded
uploadTypeIt can be 'tmp' , 'local' according to the type of CSV file and its path from where it is uploaded. 1) tmp - if file is stored at temporary location on server. 2) local - if file is stored at local path .
statusIt describes the status of file to be uploaded.when we upload a CSV its status should be "uploaded"
uploaded_byIt describes the email ID of the person who uploaded the CSV file.