K
K
K_Kotovski2020-07-06 17:47:49
WooCommerce
K_Kotovski, 2020-07-06 17:47:49

How to remove attributes in bulk?

Hello, can you please tell me how to remove attributes in bulk? I have such a problem, when importing through WP All Import, 16200 attributes were created that are not needed and it is not clear why copies were created
. There are a lot of them, even if you try to manually delete it, deleting 1 such attribute takes 3 minutes and 25 seconds
. There is no access to SQL, you need somehow solve this issue in a artisanal way, if there are none, then tell me some
woocommerce advanced bulk edit options did not help me, since it cannot load due to so many attributes

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Mikhailov, 2022-02-22
@derealty

put the php file with the code in the root of the site:

<?php
include 'wp-load.php';

$attributes = json_decode(json_encode(wc_get_attribute_taxonomies()),true);
sort($attributes);

foreach ($attributes as $key => $attribute) {
    $deleted = wc_delete_attribute( $attribute['attribute_id'] );
    echo '<pre>';
    print_r(sprintf('Deleting %s - Result %s',$attribute['attribute_label'], $deleted));
    echo '</pre>';
}

give it permissions 777 , and then
go back to your attributes (in the admin panel) and manually create a random attribute, the previously created attributes will disappear, this bug is according to wokomers support due to caching.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question