As above code, I want to add limit => -1, to apply all 6000 products.
// Change hook if needed. This will run on each refresh of the website
add_action('init','test');
function test() {
// Get variable products.
$args = array(
'type' => 'variable',
'limit' => -1,
'return' => 'ids',
);
$product_ids = wc_get_products( $args );
foreach($product_ids as $product_id) {
// Get the current parent sku
$main_sku = get_post_meta( $product_id, '_sku', true );
// If not empty clear it
if(!empty($main_sku)) {
update_post_meta($product_id, '_sku', '');
}
}
}