WooCommerce test data from your own scripts, CI and AI agents

Dave Hilditch •

If you build plugins, themes or stores on WooCommerce, every environment you stand up needs products before you can test anything in it: a fresh local site, a CI run, a branch preview, a workspace for an AI coding agent. And a test that changes products should start from a clean site, so that data gets loaded again and again.

How you load it decides how often you can afford to start clean. I use Super Speedy Imports for this in my own dev tooling, from shell scripts, test suites and the agents I work with, and this post shows how to wire it into yours. First, though, why it’s worth replacing whatever you use now.

One product at a time is the slow way

The obvious way to make test products from a script is WooCommerce’s own CLI command in a loop:

for i in $(seq 1 10000); do
  wp wc product create --user=1 --name="Test product $i" --regular_price=19.99 ...
done

It works. It’s also the slowest way there is to get 10,000 products into WordPress, because every wp call starts PHP, boots WordPress, loads WooCommerce and every other active plugin, creates one product and exits. The boot costs more than the product.

I measured it against three faster ways of doing the same job, on the same machine with the same 10,000 products.

The test

Every method started from a freshly reset WordPress site with WooCommerce active and created the same 10,000 simple products from one CSV: name, SKU, description, regular price, managed stock, and one of eight child categories under four parents. I checked each site afterwards: 10,000 published products, 10,000 rows in WooCommerce’s product lookup table, and the same name, SKU, price, stock and category on the products I spot-checked.

  1. One wp call per product. One wp wc product create per product, as above.
  2. One WP-CLI process. A single wp eval-file script that boots WordPress once and loops over the CSV calling new WC_Product_Simple() and save(). This is what you’d write yourself if you thought about it for a minute, so it’s only fair to include it. There’s a copy at the end of this post.
  3. Super Speedy Imports Lite, free on wordpress.org: wp ssi create then wp ssi <id>.
  4. Super Speedy Imports Pro, the same two commands.

The machine: my everyday dev box, an AMD Ryzen 9 5900X (12 cores) running Ubuntu 24.04 under WSL2 on Windows, with PHP 8.5, MariaDB 10.11, WordPress 7.1.4 and WooCommerce 10.5.3. No object cache, no images. It was busy with other work while these ran, and WSL2 adds overhead of its own, so a production server will be faster at every one of these methods. Don’t read the times below as how fast any of them is in general. What they show is the gap between the methods on the same box, which is the box you’d actually be waiting on. The three faster methods were each run three times and the table shows the median, with the range beside it; the slow loop takes nearly three hours, so it ran once.

The results

Method10,000 productsRange
One wp call per product2 h 41 minone run
One WP-CLI process19 min 55 s13 to 22 min
Super Speedy Imports Lite 3.40.024 s21 to 31 s
Super Speedy Imports Pro 3.74.141 s19 to 44 s

The per-product loop took about 400 times as long as Super Speedy Imports Lite. Writing the loop properly, in one process, gets you an eight-fold improvement, and it’s still about 50 times slower than the importer.

Pro and Lite overlap so much on this box that the gap between them is noise: Pro’s fastest run (19 s) beat Lite’s fastest (21 s), and its median came out slower. Don’t read anything into it. Both did the job in well under a minute.

What it does to your reset-and-reload time

Resetting one of my local test sites takes about 2 seconds (more on those sites below), so the time from “start again” to “10,000 products ready” is:

MethodReset and reloadFresh starts per hour
One wp call per product2 h 41 minnone
One WP-CLI processabout 20 min3
Super Speedy Imports Liteabout 26 sover 100

That’s before the test itself runs. With the per-product loop you get about three clean starts in a working day. With the importer, loading the data stops being the slow part.

Wiring it into your tooling

Super Speedy Imports Lite is free on wordpress.org, with no product limit, and everything in this section works in it. It’s all WP-CLI, so it behaves the same from a terminal, a shell script, a test harness, a CI job or an agent.

The three commands

wp plugin install super-speedy-imports-lite --activate
wp ssi create "Test data" product products.csv   # prints the new import's ID
wp ssi 1                                          # run it, using that ID

wp ssi create maps the file the same way the New Import screen does and prints how many columns it mapped. Name the CSV columns SKU, Name, Description, Regular_Price, Stock and Categories (with > between parent and child, so Clothing>Shirts) and they map on their own, with no mapping screen.

A seed script you can commit

This is the shape of the script I keep next to a test suite. It loads the catalogue into whichever site WP-CLI is pointed at:

#!/usr/bin/env bash
# bin/seed-products.sh: load the test catalogue into the site WP-CLI points at
set -euo pipefail
csv="$(realpath "${1:-tests/fixtures/products.csv}")"

wp plugin is-installed super-speedy-imports-lite || wp plugin install super-speedy-imports-lite
wp plugin activate super-speedy-imports-lite

id="$(wp ssi create "Test catalogue" product "$csv" | sed -n 's/^Import created successfully with ID: //p')"
test -n "$id"
wp ssi "$id"

wp ssi create prints Import created successfully with ID: 42, and the sed line picks the ID out of that. Generate the CSV with a fixed random seed, so every run and every site gets the same products, and commit the CSV or its generator alongside your tests.

The parts that matter once it’s in a script

  • It fails loudly. wp ssi exits non-zero when an import fails or a command is refused, so with set -e a broken seed stops your CI job there, rather than letting the tests run against an empty shop.
  • Re-running is safe. Run the same import again and it updates the products by SKU rather than making duplicates.
  • One import, several files. wp ssi <id> --file=/path/to/big.csv runs the same import against another CSV with the same columns, so a small catalogue for quick tests and a big one for performance work can share one set-up.
  • The mapping can live in your repository. wp ssi save-config <id> seed.json writes the import’s column mappings and options as JSON (under wp-content/uploads/super-speedy-imports/), and wp ssi load-config <id> <file> applies them to an import on another site.
  • Clearing without a full reset. wp ssi <id> --delete-all removes everything that import created.
  • XML and JSON fixtures. wp ssi convert-source products.json turns an XML, JSON or JSON Lines file into a CSV ready for wp ssi create.

The CLI reference lists every command and flag. One thing Lite won’t do: variable products, galleries, custom post types and ACF fields are in Super Speedy Imports Pro, so if your tests need variations, that’s the paid edition. Simple products, categories, attributes and featured images are all in Lite.

Giving an AI coding agent one reliable way to do it

Ask an agent to “add some test products” and it has to pick a method. You’ve no guarantee which one it’ll pick, or that it’ll pick the same one next time. If test data matters to your workflow, don’t leave that choice open. Give the agent one documented way:

  • In the project. Commit the seed script and name it in the file your agent reads at the start of a session (CLAUDE.md for Claude Code, AGENTS.md for Codex): “To load test products, run bin/seed-products.sh. Don’t create products one WP-CLI call at a time.”
  • In every project, as a skill. The parallel-dev skill in our public skills repository, superspeedyplugins/skills, has a test data section that tells the agent to put the data in a CSV and load it with the three commands above, and to write the single-process loop if it can’t use an importer. Copy the folder into ~/.claude/skills/ and Claude Code picks it up.

Then check. An instruction makes the fast way the documented way, but it isn’t a guarantee, so for the first few sessions look at the commands the agent actually ran (they’re in its transcript). If it went its own way, tighten the wording.

A site for each agent, branch or test suite

The same skill is where the 2-second reset comes from. It gives every agent, branch or test suite its own WordPress site at an address like http://tests.my-plugin.localhost:8081/, with its own database and database user, and your plugin symlinked in from its repository. A site is a directory and a database, created by copying a local WordPress core rather than downloading it, and nginx works out the document root from the hostname, so there’s no server config to change per site. When two agents share one WordPress, a half-saved file from one is a fatal error for both; with a site each, it isn’t.

It also tells the agent to clear test data when a run starts, never when it finishes. A suite that tidies up after itself destroys the evidence when it fails, and then you’re taking the agent’s word for what went wrong (don’t let it away with that). Setup is a one-off: nginx, PHP-FPM, MariaDB and WP-CLI, with the steps for Ubuntu, WSL2 and macOS in the skill’s setup.md.

Summary

  • On my dev box, one wp call per product took 2 hours 41 minutes for 10,000 products. One WP-CLI process took about 20 minutes. Super Speedy Imports Lite took about 24 seconds. A production server will be faster at all three; the gap between them is the point.
  • Three WP-CLI commands load a CSV of products, so the same seed script works locally, in CI and for an agent, and fails the job if the import fails.
  • Don’t leave an agent to choose how it loads test data. Name your seed script in CLAUDE.md or AGENTS.md, or install the parallel-dev skill from github.com/superspeedyplugins/skills, and check what it ran.

Here’s a trimmed copy of the single-process loop I measured (the full one also stops on a failed category insert), if you’d rather not install anything:

<?php // wp eval-file make-products.php products.csv
$fh = fopen($args[0], 'r');
fgetcsv($fh, null, ',', '"', '');
$cat = [];
while (($r = fgetcsv($fh, null, ',', '"', '')) !== false) {
    [$sku, $name, $desc, $price, $stock, $path] = $r;
    if (!isset($cat[$path])) {
        [$parent, $child] = explode('>', $path);
        $cat[$parent] ??= wp_insert_term($parent, 'product_cat')['term_id'];
        $cat[$path] = wp_insert_term($child, 'product_cat', ['parent' => $cat[$parent]])['term_id'];
    }
    $p = new WC_Product_Simple();
    $p->set_name($name);
    $p->set_sku($sku);
    $p->set_description($desc);
    $p->set_regular_price($price);
    $p->set_manage_stock(true);
    $p->set_stock_quantity((int) $stock);
    $p->set_category_ids([$cat[$path]]);
    $p->set_status('publish');
    $p->save();
}

Fixing this on a real store?

Super Speedy Imports does it for you. Or get every Super Speedy plugin with the All Access Pass.

Super Speedy Imports

Big supplier feeds imported and updated in minutes, not overnight

From €79.00
Get Super Speedy Imports
All Access Pass

Every Super Speedy plugin, one licence, with updates and support.

From €129.00
See the All Access Pass

Comments