WooCommerce: remove empty SKU products

At work, we got ourselves a nice WooCommerce shop. Using WP All Import, it automagically imports the products and updates stock. But somehow in we ended up with products in our database with no SKU.

Removing one of those products, and then rerun the import, seemed to work. So maybe these products where in the product feed once without a SKU. Who knows. Anyways, I wanted them gone, and didn’t want to delete the entire database, afraid of what Google may think of that.

So I checked the database a bit and came up with a SQL query. First, to check if you have products with empty SKU’s as well, you could run something like this:

To remove the products, I think this should do. Of course this wouldn’t delete the files in your upload folder. If you want to delete those as well, you might want to write a script that selects the records, and then removes the images as well.


9 thoughts on “WooCommerce: remove empty SKU products

    • I don’t have a running WooCommerce anymore. But if I were you I’d first query the suplicate SKU’s. See how many you get. You could then also create a delete query from that, using the id’s with some creative copy & pasting.

  1. Pingback: Eliminar productos duplicados por SKU en Woocommerce - Kawaineko

  2. Hello –
    This could be my saviour! I have a strange problem with my database where it is adding around 30% additional product variations when I import the database (they all have unique IDs, but no SKU). Even when I delete everything and try again, the same thing happens.

    I can use this to delete those products, but is there a way of getting rid of the product variations too?
    I know there are around 2,500 variations that need to be deleted, but the result using the query below only brings up 200 products.

    Any help would be very much appreciated!

    Kind regards,


    • Just to update, I replaced ‘product’ with ‘product_variation’ and it worked like a dream.
      Thanks for posting this on your website. I have spent over a week trying to solve all sorts of database headaches, and this has saved me!

  3. WP All Import has a setting, located in the template area, under WooCommerce Add-On > Import Options, that enables SKU duplicate checking.
    If not checked, and duplicate SKUs appear, it will import them with an empty SKU.
    Reading the above posts, it kind of clicked for me that this was the reason for this to happen.

    If so, my question is, how to check and automate the deletion of all products with empty SKU just after imports finishes?

    Thanks in advance for bringing this topic, would be great to find a way to really prevent that to happen in production!

    • I’m not sure, I am not a WooCommerce or WordPress developer. Maybe a plugin can developed if there is an WooCommerce after_import hook.

      You should be able to put the SQL query in a crontab though, that would automate it on a specific time.

Leave a Reply

Your email address will not be published. Required fields are marked *