• Resolved perlfan

    (@perlfan)


    I have two attributes in my variable products:

    • number of pages
    • language combination

    When I deselect specific attributes, the corresponding variations keep existing and are not deleted (in the variations tab, I see them with an unassociated attribute “Any number of pages”:

    As I have thousands of unused variations with unassociated attribute values, I would like to delete those. How can I select and delete them (e.g. via phpMyAdmin)? The problem is that these variations are not orphaned variations as they are just not associated to a specific attribute value anymore. So far, I understood that all variations with associated attribute values are listed in wp_term_relationships. Any help is strongly appreciated and I think this concerns many users who would like to streamline their database.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey there, @perlfan! Thanks for contacting us. I’m happy to help you.

    Let me confirm if I understood your goal correctly:

    I see on the screenshot that you have the variations with a “any number of pages” and, as I understand, you don’t want this, right? You want to have each variation separately with the specific numbers.

    And you want to delete the ones with “any number of pages”, correct?

    If you click on “remove” next to them, does it delete them? If it doesn’t, please let us know.

    If this is not what you are trying to do, do you mind sharing more details so we can better understand it? Thank you!

    Looking forward to your reply.

    Have a wonderful day!

    Thread Starter perlfan

    (@perlfan)

    Good morning and thank you for your reply!! Yes, this is pretty much it – I have two attributes (number of pages, from 1-15, and language combination, around 40 combinations) which gives hundreds of variations per product. Now, for some products, every now and then, I have to deselect certain “number of pages” values which results in hundreds of “unused” variations with an “Any number of pages” value. Removing them manually is not an option as this would take days. As variations bloat up the database significantly, I’m looking for a query / command to remove those automatically. I’ve seen others with the same problem, however, I haven’t seen a solution yet. Thanks, Frank

    Plugin Support omarfpg a11n

    (@omarfpg)

    Hi Frank @perlfan,

    I understand the issue. This counts as customization work as it goes beyond the scope of the default WooCommerce experience. However I can see the value on what you propose and it could be a nice feature request, if you’d like to make it so!

    In the time being, I’ve found a couple of workarounds that can help you fix this at this moment:

    1. Exporting your products, removing the unusued variations and importing it again, you can find more details here.
    2. Deleting the unused variations through a query, you can find an example here that you could accommodate to your scenario. Please make sure to take a full database back up before trying this. And please keep in mind that this is third party code we’re not responsible for. Try it at your own risk.

    Please let us know if there’s anything else we can do to help or if you have further questions.

    Have a wonderful day!

    Cheers!
    -OP

    Thread Starter perlfan

    (@perlfan)

    Thank you – also for the others post on the same issue that I’ve already seen though. I can make that feature request, but for the meantime, I would like to clarify the workaround solution. What would be the exact procedure to remove the variations through export/import? Am I right that I’d have to delete the post_parent column entries for all variations which have an unused attribute value? Would that make these variations into orphaned variations that can then be removed via the built-in feature? It would be important that all entries of theses unused variations would be deleted (in all tables such as postmeta). Thanks for a short follow up on this. Frank

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @perlfan

    What would be the exact procedure to remove the variations through export/import?

    To remove the variations through export/import, you can follow this general procedure:

    1. Export your products using the built-in WooCommerce product export feature. This will give you a CSV file.
    2. Open the CSV file and locate the unused variations. You can identify these by looking for the “Any number of pages” value in the “Attribute” column.
    3. Delete the rows corresponding to these unused variations. This will effectively remove these variations from your product data.
    4. Save your CSV file and then import it back into WooCommerce using the product import feature. This will update your product data, removing the unused variations.

    Am I right that I’d have to delete the post_parent column entries for all variations which have an unused attribute value? Would that make these variations into orphaned variations that can then be removed via the built-in feature? It would be important that all entries of theses unused variations would be deleted (in all tables such as postmeta).

    It’s a bit more complex. Deleting entries from the post_parent column in the database would not necessarily make these variations orphaned. The post_parent column is used to link variations to their parent product, so altering this could lead to other issues.

    Instead, I recommend focusing on the “Attribute” column in your CSV file during the export/import process. This should allow you to effectively remove the unused variations.

    I hope this clarifies your concern. If you have any other questions, feel free to ask.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Delete unused variations after deselecting attribute values’ is closed to new replies.