Skip to content

Importing WooCommerce products from CSV: variations, images, and the columns that matter

The WooCommerce product CSV importer explained column by column — variable parents and their variation rows, Images side-loading, Categories hierarchy, batch size and timeouts, plus the encoding traps that mangle a French-locale export.

WooCommerce ships a product CSV importer at Products → Import, and it will load a whole catalogue — simple products, variable parents, variations, category trees, and remote images — provided the file gives it exactly what it expects. The failures are boring and repeatable: a UTF-8 byte-order mark glued to the first header, a semicolon delimiter out of a French-locale Excel, variation rows whose Parent value resolves to nothing, and an image side-load that runs past max_execution_time and leaves half a catalogue published. This article covers the column schema that actually matters, a working example file, the batch-size and timeout controls, and the queries that tell you whether the import finished or just stopped.

What you’ll accomplish

  • Write a CSV whose header row the importer auto-maps without manual intervention
  • Import variable products with their variations linked correctly through Parent
  • Get product images side-loaded as real attachments instead of broken hotlinks
  • Survive a mid-import timeout on shared hosting, and resume without duplicating products
  • Verify product, variation, and attachment counts after the run rather than eyeballing the catalogue

Prerequisites

  • WooCommerce 9.x or 10.x on WordPress 6.5+. The importer has been core since WooCommerce 3.1 and the column names below have been stable throughout.
  • An administrator account. The importer checks the import capability, so editors and shop managers cannot reach it by default.
  • A staging copy of the store. Every import in this article should be run there first — the importer has no undo, and a bad category column creates hundreds of terms you then have to clean up by hand.
  • SSH and WP-CLI on the host for the verification steps. The browser-only path works, but you lose the ability to count anything afterwards.
  • HPOS (High-Performance Order Storage) does not affect products at all — products and variations still live in wp_posts and wp_postmeta regardless of the order storage setting. If you have been putting off an import because of an HPOS migration, they are unrelated.
  • Image URLs that are publicly reachable from the WordPress server. The importer fetches them server-side, so a staging site behind HTTP basic auth cannot pull images from itself.

How it works

The importer reads the header row, maps each header to an internal field, then processes data rows in batches. Each batch is a separate admin-ajax request; the progress bar you see is the browser firing one request after another until the row cursor reaches the end of the file.

A variable product is not one row. It is a parent row with Type set to variable that declares the attribute names and the full set of values, followed by one row per variation with Type set to variation and a Parent column pointing back at the parent. The parent row’s Attribute 1 value(s) holds every value the attribute can take, separated by commas; each variation row’s Attribute 1 value(s) holds exactly one of them.

CSV rows on the left mapping to a WooCommerce variable product with two variations, category terms, and side-loaded image attachments on the right

The columns worth knowing precisely:

  • ID and SKU — the matching keys. Leave ID blank to insert. If SKU matches an existing product, WooCommerce updates that product instead of creating a second one, which is what makes re-running a failed import safe.
  • Type — simple, variable, variation, grouped, or external. A variation row with no valid parent is silently useless.
  • Parent — either the parent’s SKU (TS-BASE) or id: followed by the parent’s numeric post ID (id:412). The SKU form is the one to use for a fresh import, because you do not know the IDs yet. The id: form is for updating variations on products that already exist.
  • Attribute 1 name / Attribute 1 value(s) / Attribute 1 visible / Attribute 1 global — four columns per attribute, numbered upward for Attribute 2, Attribute 3, and so on. visible is 1 or 0 for display on the product page. global is 1 to use a global attribute taxonomy (pa_size) or 0 for a per-product custom attribute. Use 1 for anything you intend to filter or facet on.
  • Categories — > builds hierarchy, , separates siblings. Apparel > Tees, Sale puts the product in the Tees child of Apparel and in a top-level Sale. Missing terms are created on the fly, which is exactly why a typo costs you a cleanup pass.
  • Images — comma-separated absolute URLs. The first one becomes the featured image, the rest become the gallery. WooCommerce side-loads each one: an HTTP GET, a write into the uploads directory, an attachment post, then thumbnail regeneration. This is by far the slowest step.
  • Published — 1 published, 0 draft, -1 private. Visibility in catalog — visible, catalog, search, or hidden. Sites running en_CA or en_GB see this header spelled Visibility in catalogue in the admin UI; both spellings auto-map, and the untranslated Visibility in catalog is the safe one to write in the file.
  • Meta: key — anything after Meta: becomes a postmeta key verbatim. Meta: _supplier_code writes _supplier_code. This is how third-party plugin fields get imported, and the leading underscore matters if the plugin expects a protected meta key.

Step-by-step

  1. Build the header row from WooCommerce’s own export. Before writing anything by hand, go to Products → Export, export the handful of products already in the store, and use that header row as your template. It is the authoritative list of column names for your exact WooCommerce version and locale. Then trim it to the columns you actually populate — the importer does not require every column.

  2. Write the file. A minimal catalogue with one simple product and one variable product with three sizes:

ID,Type,SKU,Name,Published,"Visibility in catalog","In stock?",Stock,"Regular price",Categories,Images,Parent,"Attribute 1 name","Attribute 1 value(s)","Attribute 1 visible","Attribute 1 global"
,simple,MUG-01,Camp mug,1,visible,1,40,18,Kitchen > Drinkware,https://assets.example.com/mug-01.jpg,,,,,
,variable,TS-BASE,Basic tee,1,visible,1,,,Apparel > Tees,"https://assets.example.com/tee-front.jpg,https://assets.example.com/tee-back.jpg",,Size,"S, M, L",1,1
,variation,TS-BASE-S,Basic tee - S,1,visible,1,12,29,,,TS-BASE,Size,S,1,1
,variation,TS-BASE-M,Basic tee - M,1,visible,1,20,29,,,TS-BASE,Size,M,1,1
,variation,TS-BASE-L,Basic tee - L,1,visible,1,8,32,,,TS-BASE,Size,L,1,1

Note the shape: sixteen columns on every row, quotes around any value containing a comma, Categories and Images empty on variation rows because variations inherit both from the parent, and Parent empty on the parent row.

  1. Check the encoding and delimiter before uploading. This is the single most common failure for a Quebec or French-locale team, because Excel with a French regional setting exports semicolon-delimited Windows-1252 with a BOM.
file -I products.csv
head -c 3 products.csv | xxd

Expected output is text/csv; charset=utf-8 and three bytes that are not efbb bf. If you see the BOM or a non-UTF-8 charset, normalise the file in one pass:

python3 - <<'PY'
import csv
src = csv.reader(open('export.csv', newline='', encoding='utf-8-sig'), delimiter=';')
out = csv.writer(open('products.csv', 'w', newline='', encoding='utf-8'))
out.writerows(src)
PY
wc -l products.csv

utf-8-sig strips the BOM; the writer emits comma-delimited UTF-8 without one. Adjust encoding to cp1252 if file -I reported Windows-1252. The wc -l line count should equal your row count plus one for the header.

  1. Lower the batch size on modest hosting. The importer defaults to 30 rows per AJAX request, which is fine for text-only rows and far too many when each row side-loads three images. Drop it in a small must-use plugin:
<?php
// wp-content/mu-plugins/import-tuning.php
add_filter( 'woocommerce_product_import_batch_size', function () {
    return 5;
} );

Confirm it is loaded before you start:

wp eval 'echo apply_filters( "woocommerce_product_import_batch_size", 30 ), PHP_EOL;'

Expected output: 5. Also confirm the PHP time limit the importer will run under, since a 30-second ceiling is what kills most shared-hosting imports:

wp eval 'echo ini_get("max_execution_time"), " ", ini_get("memory_limit"), PHP_EOL;'

Aim for at least 120 seconds and 512M for the duration of the import. Raise it in the host’s PHP settings rather than in wp-config.php, since set_time_limit() is frequently disabled.

  1. Upload and map. Go to Products → Import, choose the file, and expand Advanced options if your delimiter is anything other than a comma. On the mapping screen, scroll the whole list. Any row whose right-hand dropdown reads Do not import is a column WooCommerce did not recognise — that is where a stray Attribute 1 value (s) with an extra space, or a translated header from another store’s export, shows up. Fix the header in the file and re-upload rather than mapping by hand, so the next run is repeatable.

  2. Run it, and expect to run it twice. Leave the browser tab in the foreground; the importer is driven by JavaScript in that tab and backgrounded tabs get throttled. If it stalls, re-run the identical file. Because SKU matching updates rather than inserts, the rows that already landed are updated in place and the rest are inserted.

  3. The WP-CLI alternative. There is no core WP-CLI command that consumes a WooCommerce product CSV. wp import handles WXR (WordPress eXtended RSS) files only and will reject a CSV outright. What does exist is the WooCommerce CLI, one product per invocation:

wp wc product create --user=1 --name="Camp mug" --sku=MUG-01 \
  --type=simple --regular_price=18 --manage_stock=true --stock_quantity=40

Expected output: Success: Created product 415. Driven from a shell loop over a CSV this is slower per product than the batch importer, but it never times out a browser tab and each failure is visible on its own line — worth it for a catalogue you have already failed to import twice.

Validate it works

Counts first, spot-check second. Run all four before telling anyone the catalogue is live.

wp post list --post_type=product --format=count
wp post list --post_type=product_variation --format=count

Expected output: two integers matching the parent rows and variation rows in your file. If the variation count is short, a timeout cut the file off partway.

Find variations whose parent never made it:

wp db query "SELECT COUNT(*) AS orphans FROM wp_posts v
  LEFT JOIN wp_posts p ON p.ID = v.post_parent AND p.post_type = 'product'
  WHERE v.post_type = 'product_variation' AND p.ID IS NULL;"

Expected output: orphans followed by 0. Anything else means Parent values that did not resolve.

Confirm images are attachments, not hotlinks. This counts published products with no featured image:

wp db query "SELECT COUNT(*) AS no_image FROM wp_posts p
  LEFT JOIN wp_postmeta m ON m.post_id = p.ID AND m.meta_key = '_thumbnail_id'
  WHERE p.post_type = 'product' AND p.post_status = 'publish' AND m.meta_id IS NULL;"

Expected output: 0, unless you deliberately imported products without images.

Then open one variable product in the admin, click the Variations tab, and confirm every size shows its own price and stock. A parent with an attribute but zero variations listed is the classic signature of variation rows that imported as orphans.

Troubleshooting

The five stages of a WooCommerce CSV import — upload, column mapping, batched insert, image side-load, term assignment — each annotated with the failure it produces

The import stops partway with no error. The AJAX request hit max_execution_time, a PHP memory ceiling, or a proxy read timeout. Lower woocommerce_product_import_batch_size to 5 or even 1, raise the PHP time limit, and re-run the same file. Check the server error log for the exact wall it hit rather than guessing — wp eval 'echo ini_get("error_log"), PHP_EOL;' tells you where that is.

Images did not import. Confirm the URL is reachable from the WordPress server, not just from your laptop: curl -sI https://assets.example.com/tee-front.jpg | head -1 should return HTTP/2 200. Staging sites behind basic auth, IP allowlists, or a host-level firewall block their own side-loads. A URL that redirects to an HTML error page produces an attachment containing HTML, which is worse than a failure because it looks like it worked.

Variations imported as standalone products or vanished. Two causes. Either Type on those rows is not exactly variation, or Parent does not match a SKU that exists — in the file or already in the store. The importer processes rows in file order, so parent rows must appear before their variations. Also check that Attribute 1 name on the variation matches the parent’s spelling character for character; Size and size produce different terms.

Accented characters came through as é or ?. The file was Windows-1252 or Latin-1 and got read as UTF-8, or the reverse. Re-normalise with the Python snippet in step 3 and re-run the import — the SKU match will overwrite the mangled titles. If the mangling reached the database, fix the source file and re-import rather than running a find-and-replace, which will miss the term names.

Duplicate products appeared. Either the SKU column was left unmapped, or your source data has trailing whitespace in SKUs so TS-BASE and TS-BASE are different keys. Strip whitespace in the export step, and check for the damage with wp db query "SELECT meta_value, COUNT(*) c FROM wp_postmeta WHERE meta_key='_sku' GROUP BY meta_value HAVING c > 1;" — expected output is an empty result set.

When this is the wrong approach

The CSV importer is a one-shot bulk load, not a pipeline. If your catalogue lives in a PIM or an ERP and changes daily, build against the WooCommerce REST API instead — a nightly CSV re-import rewrites every product row and every attachment reference, churns the database, and blows out object caches for no reason.

Past roughly 50,000 SKUs the browser-driven importer stops being reasonable: an interrupted run leaves a half-published catalogue, and the diff between “what the file said” and “what the store has” becomes its own project. At that scale, script the load against the REST API or WP-CLI with your own checkpointing, run it against a database you can restore, and keep a per-SKU log.

And if you are moving an existing store rather than seeding a new one, a CSV round-trip is the wrong tool entirely — it loses orders, customers, and reviews. See WooCommerce data migration between stores for that path, and run a WooCommerce migration preflight audit before you touch anything. The importer’s own reference documentation lives in the WooCommerce documentation.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.