<?php
/*
Plugin Name: Bulk Updater
Description: This is not just a plugin, it's <em>CODE</em>..
Author:
*/
//add_action('init','KF_update_all_posts');
function KF_update_all_posts(){
$my_posts = get_posts( array('post_type' => 'catalog', 'numberposts' => -1 ) );
foreach ( $my_posts as $my_post ):
$post_id = $my_post->ID;
$value = 'P-' . $post_id;
if(!get_field('product_sku', $post_id)){
update_field('product_sku', $value, $post_id);
}
wp_update_post( $my_post );
endforeach;
}