CSV Import
EverShop can import categories, products, customers and customer addresses from CSV files. You upload a file in Admin → Import, EverShop checks the whole file and shows you every problem, and when the file is clean you start the import. The import runs in the background, so you can leave the page, and it uses the same services as the admin forms, so the same rules apply to imported records as to records you type in.
How it works
- Choose what to import and download the template for it: a CSV with the header row and two example rows. The template also has one
attr:column for each attribute and onemetafield:column for each custom field that exists in your store. - Upload the file. A new upload for a type replaces an unfinished import of the same type. The page asks first if the unfinished one belongs to another admin, or if it was stopped after it had written rows.
- Wait for the check. The file is read twice: first for what the rows say, then against your store (does the category exist, is the SKU already used, …). Problems are listed with the row, the column and a message. Download file with errors gives you the whole file with a
_errorscolumn, so you can fix it in a spreadsheet and upload it again. Check again runs the check again on the file you already uploaded, for example after you created a missing category. - Start the import when the check found no errors. Warnings do not stop it. The import checks the file once more just before it writes anything, because the store may have changed since the first check.
- Follow the progress. The page shows the rows done and the bar, and keeps updating while the import runs. Cancel stops between two rows; what was written stays. If the import stops after 10 failed rows, or the server restarts, Resume continues where it stopped.
A column that the type does not have (a column from another system, for example) is ignored, with a warning. When more than half of the columns of the file are ignored, the first warning says so ("17 of 23 columns were ignored because this type of file does not use them"): check that you chose the right type of file before you start the import.
Only one import runs at a time in a store, and a type has only one unfinished file. Finished imports are kept in the list for 7 days.
Categories, then products, then customers, then customer addresses. A product refers to a category and an address refers to a customer, and those must exist when the file is checked.
What every file follows
| Rule | Detail |
|---|---|
| Format | UTF-8 (a byte order mark is fine), comma separated, the first row is the header. Header names are lower case with underscores. |
| Blank cell | On a new record it means "not provided". On an existing record it means leave as it is. There is no way to clear a field with a blank cell. |
| Booleans | 1, 0, true or false. |
| Lists | Separated with |, for example a|b|c. |
| References | Other records are named by name or code, never by id (ids differ between stores): a category by its url_key, an attribute group, tax class, package or customer group by its name. Letter case is ignored. A name that matches more than one record is an error. |
| Custom columns | attr:<attribute_code> for a product attribute, metafield:<namespace>.<key> for a custom field. The attribute or definition must already exist in the store; the import never creates one. |
| Update or create | A row whose key already exists updates that record; otherwise it creates one. Choose "Only create" or "Only update" on the upload page to refuse the other case. Customer addresses are never matched: they are only added. |
| Example rows | The rows of the template use reserved keys (EXAMPLE-SKU-1, example-category, …). They are skipped with a warning, so uploading the template as it is writes nothing. |
Categories
| Column | Needed to create | Notes |
|---|---|---|
url_key | no | The key of the row. When blank it is made from name. |
name | yes | |
parent | no | The url_key of the parent. It may be anywhere in the file, or already in the store; parents are written first. |
status | yes | 1 or 0. |
position | no | A whole number from 0 to 32,767. |
description, meta_title, meta_description | no | A description may be plain text or HTML. |
image | no | An http(s) URL. The image is copied into your store's file storage. |
Products
| Column | Needed to create | Notes |
|---|---|---|
sku | yes | The key of the row. |
name | yes | |
url_key | no | Made from name when blank on a new product. An update with a blank cell keeps the stored one, so renaming never changes the address. |
status, visibility | yes | 1 or 0. |
price | yes | 0 or more, up to 2 decimals. |
qty | yes | A whole number. |
manage_stock, stock_availability | yes | 1 or 0. Without them a product would be unmanaged and out of stock, so they are required. |
attribute_group | yes | The name of the attribute group. |
package | no | The name of a package. A shippable product with a blank package gets the default package. |
no_shipping_required | no | 1 for a product that is not shipped. |
weight, tax_class | no | The tax class by name. |
category | no | One category, by url_key. |
short_description, description, meta_title, meta_description | no | |
images | no | |-separated URLs; the first is the main image. On an update a non-blank cell replaces the product's images with exactly this list. |
variant_group, variant_axes | no | Rows with the same variant_group label become one group of variants. variant_axes lists the attribute codes that tell the variants apart, for example color|size (at most 5, all of type select). The rows of a group must be next to each other in the file. |
redirect_from | no | |-separated old paths; each becomes a permanent (301) redirect to the product. Existing redirects stay. |
attr:<code> | if the attribute is required | The option text for a select, |-separated texts for a multiselect, free text otherwise. The attribute must be in the product's attribute group. |
Updating a product that belongs to a group of variants also changes the other members of the group for the fields they share (tax class, category, shipping, weight, package and the attributes that are not axes), so all rows of a group in the file must agree on them.
Customers
| Column | Needed to create | Notes |
|---|---|---|
email | yes | The key of the row. Letter case is ignored when deciding whether a customer exists. |
full_name | yes | |
status | no | |
group | no | The name of a customer group. Blank means the default group. |
password_hash | no | A bcrypt hash ($2a$, $2b$ or $2y$, cost 04 to 15), stored as given. Hashes of other kinds (WordPress, MD5, …) cannot be used: they would be stored but never match. |
password | no | A plain password (6 characters or more), hashed on import. Allowed but not recommended: the file holds a secret. Not together with password_hash. |
A customer with no password gets a random one that nobody knows. They use Forgot your password? on the login page to choose theirs; the import sends no e-mail. Passwords are ignored when a customer already exists, so importing a file again never resets a password a customer has changed.
Customer addresses
One row for each address, the customer named by email (the customer must already exist). The columns follow the address format of the country: recipient (or given_name and family_name if your store uses a split name), organization, address_line_1, address_line_2, address_line_3, locality, dependent_locality, administrative_area (the region key, for example US-CA), postal_code, sorting_code, country (two letters, for example US), telephone, extra (a JSON object for the extra fields a package registers for the country) and is_default (1 makes it the customer's default address).
The import runs each address through the same checks as the account page, so what is required depends on the country: the United States needs a locality, a region and a postal code, Germany needs no region. Addresses are only added: importing the same file twice adds every address twice.
Descriptions, images and custom fields
- Descriptions. Plain text becomes paragraphs (an empty line starts a new one); text with HTML tags is kept as HTML, cleaned of anything unsafe.
- Images. Only
http(s)URLs are supported. EverShop downloads each image once, checks that it is really an image (JPEG, PNG, GIF, WebP and a few others; SVG is refused), and stores it in your file storage; it never links to the other site. Importing again replaces the stored file instead of adding a copy (the folder of a file comes from its URL:catalog/<8 digits>/<8 digits>; images imported before this layout keep their old folder, and an import of the same URL writes a new copy). A URL that cannot be fetched fails the row, with a message. Tick Check that image URLs can be reached while validating if you want to find such URLs before you start (slower). - Custom fields. One column
metafield:<namespace>.<key>per definition. A cell is read by the field's type (text, number,1/0for a boolean,YYYY-MM-DDfor a date,#RRGGBBfor a color, JSON for a group,|-separated for a list). The field's own rules (range, choices, required) apply.
When something goes wrong
| You see | What it means |
|---|---|
| The check found errors | Nothing is written until the file is clean. Read the table, or download the file with errors, fix it and upload it again (or use Check again if you fixed the store, not the file). |
| "The file was checked again when the import was about to start, and new problems were found." | The store changed between the check and the start (for example a category was deleted). Nothing was written. Fix the cause and start again. |
| Stopped after 10 failed rows | The import stops itself so that a systematic problem does not fail the whole file. Fix the cause and press Resume: the failed rows are tried again and the import continues. |
| Interrupted | The server restarted or the background process stopped. Press Resume: it continues from the last saved row. |
| "The import has not started yet" for more than two minutes | The store's background process (it also sends events and runs scheduled jobs) may not be running. |
| "Slowing down so the store stays fast" | The import waits for the store's event queue (search updates, webhooks, page addresses) to catch up before it goes on. This is normal on a large import. |
After an import of products or categories, the page addresses (URLs) are finished in the background and can take a few minutes on a large file.
The language of the messages
The problems in the table, the _errors column of the file with errors and the reason a job stopped are shown in the language of the store (Settings → Store language), in the 17 languages EverShop is translated into. Names of columns and the values from your file stay as they are. A problem is stored as a sentence and its values, so if you change the store's language, an old import reads in the new one. The sentences are in translations/<locale>/import.csv, with ${1}, ${2} ... for the values; a developer who adds a message adds it to every language (a test fails otherwise).
Running it on a live store
- The import runs in a separate process and writes through the same services as the admin, in small steps, so the store stays responsive. If the store's event queue grows too long it pauses until the queue shrinks.
- Every product and category you import fires the same events as if you had saved it in the admin: webhooks, search indexing and page addresses. A large import therefore causes a burst of events.
- A file is limited to 100 MB and 200,000 rows by default. Split a larger file.
- A slow upload can be cut. The upload is one request. EverShop sets no time limit of its own, but Node.js ends a request after 5 minutes by default, and a proxy or load balancer in front of the store often allows less. If a large file does not arrive on a slow connection, split the file or raise the limit of the proxy.
- How long it takes. In our tests, 50,000 simple products without images took about 10 minutes on a fast laptop (around 85 products a second) and about 22 minutes on a standard cloud machine with 4 CPUs (around 37 a second), and the storefront answered as fast as when idle. Your speed depends on the server and the database. Images take longer, because each one is downloaded from its URL: the more images and the slower their host, the longer the import.
- Customer data in the file is kept in the database (with the problems list) for as long as the import is kept, 7 days by default, and is removed at once when you delete the import.
Configuration
All keys are optional and go under system.import in your configuration file (see the Configuration Guide).
| Key | Default | Description |
|---|---|---|
maxFileSizeMb | 100 | The largest upload, in MB. |
maxRows | 200000 | The most rows in a file. |
maxCellLength | 65536 | The longest cell, in characters. |
maxIssues | 100000 | The most problems kept for one import and phase. The page says when more exist than are listed. |
retentionDays | 7 | How long a finished import is kept. |
imageTimeoutSeconds | 30 | How long one image download may take. |
imageConcurrency | 4 | How many images are fetched at the same time. |
maxWorkersPerInstance | 2 | How many import workers one server instance runs at a time. |
workerMemoryMb | 1024 | The memory ceiling of an import worker. |
lockTimeoutSeconds | 10 | How long a statement of an import worker waits for a lock held by someone else (lock_timeout). A row that times out is tried again after 1, 3 and 9 seconds like any short failure of the database. |
eventBacklogHigh, eventBacklogLow, eventBacklogMaxWaitMinutes | 500, 100, 30 | The import pauses when the event queue has more than High events, goes on below Low, and gives up (the import becomes "interrupted") after MaxWait minutes. |
allowPrivateNetworks | false | For testing only: allow image URLs that point to a private address. |
REST API
The admin page uses a REST API that you can also call from your own tools: see the Import API. Calls that change an import must send the header X-Import-Request: 1.
Related
- Metafields — the custom fields that
metafield:columns fill - Address Formats — the address rules that the addresses file follows
- Events and Subscribers — the process that starts the import worker
- URL Redirects — the 301 redirects that
redirect_fromcreates