This guide describes how to export products from the Saleor GraphQL API. Exporting products can be useful for creating backups of your data or for easy and quick bulk editing.
You can export all products, filtered products, or products with specific IDs. Products data can be exported to CSV or XLSX file, but CSV file is recommended because it is much less time-consuming to generate. You can also define which fields will be exported. If any product variants fields are specified then products and variants data are exported. Link to download file is sent by email to the requestor. If any error occurs then email with information about problems is sent.
When the export is made by the
App email is not sent. You can get the file by query the
ExportFile with ID returned from
Each row in the exported file represents a single product variant, but it also contains general product fields. For example, if a product has three variants, there will be three lines in total. Each line will contain common product fields such as name or description, and fields specific to given variant:
|id||name||description||variant sku||variant weight|
|61||Orange Juice||No additives, no preservatives||12345||500 g|
|61||Orange Juice||No additives, no preservatives||32145||1000 g|
|61||Orange Juice||No additives, no preservatives||45123||1500 g|
The exact shape of the file depends on the fields selected for export
exportInfo input fields). If no variant fields are provided,
each row will contain only product fields:
|61||Orange Juice||No additives, no preservatives||juices||500 g|
|65||Apple Juice||No additives, great taste||juices||1000 g|
|101||Polo Shirt||Nice and comfortable||polo-shirts||200 g|
The charts below explains workflow of the exporting products:
Products can be exported only by logged users with
To export products, use
This mutation takes the following input:
scope: determine which products should be exported. You can choose between exporting all products (
ALL), filtered products (
FILTER) or selected IDs (
IDS). You can find more details in the next sections.
filter: defines filtering option. This field is optional but must be specified if your choose
ids: a list of products IDs to export. This field is optional but must be specified if
fileType: defines exported file type. You can choose between
exportInfo: determine exported fields. It takes the following input:
attributes: list of attribute IDs to export (optional).
warehouses: list of warehouse IDs to export (optional).
fields: list of product and variants fields to export (optional,
IDfield is exported by default).
As a result, this mutation returns
ExportFile object which is a
It corresponds to running export background worker, keeps task status, and created file.
ExportFile object contains the following fields:
id: a unique export file ID. Could be use to check export status.
status: status of running job.
user: instance of
Userwho requested exporting products. Set to
nullif export requested by
app: instance of
Appwhich requested exporting products. Set to
nullif export requested by
createdAt: the date and time when the export was started.
updatedAt: the date and time when the job was last time updated.
url: URL to the exported file. Set to
nullwhen the file doesn't exist yet.
events: a list of events associated with the export.
In addition the following field is available on the mutation results:
exportErrors: a list of errors that occurred during mutation execution.
The following example shows how to export all products with all available fields
to CSV file. (For exporting to XLSX just replace
Fields order defines order of headers in exported file. Exporting any of
currency field by default.
In response we get workers information:
Once the task is finished, the
url field will contain the URL address of the
exported file. If export was triggered by
User the link to the file will be sent by email
to the requestor.
To check if URL is ready you can just fetch
ID with use of
Example response with URL address to the file.
To export only filtered products you need to define
field. Lets see an example for exporting only published products from two specific
To export only products with provided ids you need to define
field. Lets see an example:
To export data about specified warehouses and attributes you need to provide list of warehouses or attributes IDs.
If you specify warehouses, then for all variants with stocks in given warehouse,
data about stock quantity will be exported. It will be visible in column:
warehouse-slug (warehouse quantity).
If you specify attributes, then data about given attribute value for all
products and variants will be exported (empty if not exists).
Attributes value will be visible in column:
attribute-slug (product attribute) for product attributes and
attribute-slug (product attribute) for variant attributes.
Below you can find example of exporting warehouses and attributes data.