How do I write Title + Variation in products _SKU (for a simple product only Title)? This is necessary to update existing products in the store (more than 8000) via WP All Import and add new ones. Now updates only simple products..
I’m trying this, but still not working…
function wpse_177056_init_shortcode() {
$args = array(
'post_type' => 'product'
);
$products = new WP_Query( $args );
if ( $products->have_posts() ):
while ( $products->have_posts() ):
$products->the_post();
update_post_meta( $post->ID, '_sku', 'test' );
endwhile;
endif;
}
add_action( 'init', 'wpse_177056_init_shortcode' );
2
Answers
Set more time limit if you have a lot of products...
You can use set_sku function to update SKU’s