question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSV import/export

See original GitHub issue

Implement CSV import/export for products.

Export

Proposed API:

type Mutation {
  exportProducts(scope: ExportScope, filter: ProductFilterInput, ids: [ID!]): Job!
}

enum ExportScope {
  ALL
  IDS
  FILTER
}

type Job {
  id: ID!
  status: String!
  createdAt: DateTime!
  url: String
}

Description

Mutation triggers a Celery task that takes given queryset of products and exports them to a file. As a result of the mutation, we return a Job object that informs about the status of the operation. Once the task is finished, Job will contain a link to download the CSV file (or a dashboard view with the report and download link). We will send this link in an email to the user who requested the operation.

Job objects could be used in the dashboard to render a list of scheduled jobs, query their status or access past exports, but we’ll need to agree if this in the scope of this PR.

Parms: My idea is to use scope, filter and ids to determine which products to export. filter would be of the same shape as filter used in the products query, so we can filter out some products first on the list and then export them. ids is to allow exporting only selected set of product ids. There is also the ability to export all products in the database. The scope param would determine which of these three export options to use.

Permissions: MANAGE_PRODUCTS (or specific permission only for import/export - needs to be discussed)

Import

type Mutation {
  importProducts(file: Upload!, updateExisting: Boolean!, updateStock: Boolean!): Job!
}

Description

Mutation passes the uploaded file to a task that reads and parses the file. For each row, we create necessary model instances, create connections between them and save them in the database. Once the task is finished we send an email to the staff user who requested the operation with a report about the number of successful/failed rows and/or errors that occurred.

Params:

  • updateExisting - if true and there is a product/variant ID in CSV that already exists in the database, the import will override these products with data from CSV. If false, lines that refer to existing products will be skipped.
  • updateStock - whether to update stock quantities with values from the CSV file. This is to guard against overriding the inventory accidentally with quantities that may be outdated in the file.

Permissions: same as exportProducts mutation.

Notes

  • Rows in the CSV file will represent either products or variants. We will assume that the first line (after the header line) will represent a product and the following lines will represent its variants until the importer recognizes the next product.
  • Product images will be exported as URLs; when importing we also expect URLs where we’ll download the images from.
  • The importer should be able to create new products, variants, attributes with values and images. For some other related objects, we’ll assume that they exist in the database and we’ll match them by IDs or slugs: warehouses, categories, collections, product types.
  • The exact shape of CSV will be agreed on once we start working on this feature.

This is a draft and I’m open to suggestions, so we end up with API that we all agree with. The details of the shape of the proposed API is also to be adjusted if I missed something.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
aliasgartaksalicommented, Sep 17, 2020

Hey! Any progress on the tool? When can we expect it? Will be very helpful.

7reactions
itsgauravjain22commented, Mar 13, 2020

I also need csv import export feature. Currently using woocommerce but can’t switch to saleor due to this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Import or export text (.txt or .csv) files - Microsoft Support
Export data to a text file by saving it · Go to File > Save As. · Click Browse. · In the Save...
Read more >
Using CSV files to import and export products
You can use a CSV (comma-separated values) file to import products into your Shopify store, and to export products from your store. When...
Read more >
Import/export CSV files to Excel - Ecwid support
Exporting CSV files from Excel · Open an Excel document. · In Excel top menu go to File → Save as. · Type...
Read more >
CSV import and export - Flowfinity
Simplify data management between Flowfinity and external systems through CSV import and export. Easily add, delete, merge, or replace records in your database....
Read more >
Import/export CSV files - QuickBooks - Intuit
Go to the Lists menu, then select Item List. Select the Excel drop-down, then choose Export all Items. In the Export window, choose...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found