• Resolved webmastermh

    (@webmastermh)


    Hi

    I try to run the command below in my SQL database to remove all ghost products that gets back at random after I try to delete them. But this command crashes my database. Whats wrong?
    gfzc is my table name.

    DELETE relations.*, taxes.*, terms.* FROM gfzc_term_relationships AS relations INNER JOIN gfzc_term_taxonomy AS taxes ON relations.term_taxonomy_id=taxes.term_taxonomy_id INNER JOIN gfzc_terms AS terms ON taxes.term_id=terms.term_id WHERE object_id IN (SELECT ID FROM gfzc_posts WHERE post_type=’product’);# 421 rows affected. DELETE FROM gfzc_postmeta WHERE post_id IN (SELECT ID FROM gfzc_posts WHERE post_type = ‘product’);# 3131 rows affected. DELETE FROM gfzc_posts WHERE post_type = ‘product’;# 129 rows affected.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @webmastermh!

    What exactly do you mean by ghost products? Are these orphans you are referring to? If so, there is a button in your “WooCommerce > Status > Tools” page you can use to remove them without the need for a SQL query.

    Cheers!

    Thread Starter webmastermh

    (@webmastermh)

    The definition would be 78 product that are counted but doesnt appear under products at one moment but at another moment a few of them appear. When I try to delete them they wont be fewer, and this loop doesnt end.

    Feels like products are floating around the database some way.

    I have tried to delete this products just the way you mention above, but unfortunately without success

    Missy a11n

    (@m155y5)

    Automattic Happiness Engineer

    Hi @webmastermh

    This sometimes happens when the column Published is not set in your CSV file when you import products. Did you recently import these products?

    To correct this, you need to set one of these values in that column and re-import the file:
    Private – set to 0
    Draft – set to -1
    Published – set to 1

    After that you can re-import the same products and they should be available to edit in your products dashboard.

    Or you can edit those fields in your database instead and they should then be visible in your products list.

    Plugin Support Thu P. a11n

    (@thup90)

    Hi there,

    I hope you found the previous reply helpful. We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Remove all (ghost) product through SQL’ is closed to new replies.