Add the following code to your functions.php. Go to any page and add ?start=ja after your site URL
add_filter('the_content','aanpassing');
function aanpassing($content){
if ($_GET['start']=="ja"){
echo 'start';
$query_args = array(
'post_type' => ['product', 'product_variation'],
'posts_per_page' => -1,
);
// The Query
$the_query = new WP_Query( $query_args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
$sku = get_post_meta( get_the_ID(), '_sku', true );
if (empty($sku)){
echo get_the_ID() .' '. get_the_title().' '. get_post_meta( get_the_ID(), '_sku', true ) .'<br>';
update_post_meta(get_the_ID(),'_sku','TMP-'.get_the_ID());
}
}
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
}
return $content;
}