Advanced

Trashed items and deletes

Published

When you turn on Delete missing items, an import does more than add and update products. Any item that exists in your store but is not in the CSV you are importing is treated as no longer wanted. This article explains where those items go, how a later import can bring them back, and how to remove them for good at scale.

What Delete missing items does

With Delete missing items enabled, the plugin compares your store against the CSV. Rows in the CSV are created or updated as normal. Items that belong to this import but are absent from the CSV are moved to the Trash rather than being erased. Trashing rather than deleting is deliberate: it gives you a safety net, so a bad feed or a truncated export does not wipe your catalogue outright.

Re-importing restores trashed items

If an item goes to the Trash and then reappears in a later CSV, re-running the import restores it. Matched items are lifted out of the Trash as part of the same update that refreshes their fields, so a re-import brings a trashed catalogue back to life.

This closed a real trap in earlier versions. Deleting products, whether through the WordPress Trash or the plugin’s delete-all, and then re-running the import used to match the trashed items and update every field while the store stayed empty, because nothing set the item’s status back to published. From 2.73.0 the update stage sets the status back, so a matched trashed item returns as a live item. This is verified at 500,000 rows.

Seeing what is in the Trash

After a run that moves items to the Trash, the import shows how many of its items are now trashed and gives you a Delete trashed items permanently link. The product count is also split into live versus trashed figures.

The split matters. Trashed items keep their tracking tag, so before this change a delete-to-trash run left the overall count unchanged and looked as though the delete had done nothing. The live-versus-trashed breakdown makes it clear what happened: the live count feeds the ordinary delete-all link, and the trashed count feeds the "in the Trash" note and the fast permanent-delete link.

Deleting trashed items permanently

The WordPress Trash screen deletes one item at a time, which is unusable for large catalogues. The Delete trashed items permanently link avoids that. It runs through the normal import runner as a deletes pass, narrowed to just this import’s trashed items, and always deletes them for good. Because it is a bulk pass rather than a per-item screen, it stays fast at scale.

Doing the same from WP CLI

The command line has a matching flag. Add --trashed-only alongside --delete-all to run the permanent delete for an import’s trashed items, exactly as the Delete trashed items permanently link does in the admin. It filters the run down to the deletes pass, skips CSV loading and worker spawning, and force-deletes only the trashed items belonging to that import.

Related reading

For the wider picture of what a partial import changes and what it leaves alone, see Partial imports: what gets updated, what stays. For the mechanics of how the pipeline runs its stages, see How imports work: the stage pipeline.

Comments

▲
▼
1/1