我们有一个网站超过1200个sku的是错误的,我们想删除他们都不影响产品。
有没有更快的方法通过phpmyadmin中的db来完成这项工作。
任何帮助都是最好的。
谢谢
发布于 2018-04-16 23:06:00
这就是你的解决方案。更改每页的post参数和sku的post元值。(未测试)
https://www.themelocation.com/how-to-updateadd-sku-of-all-products-in-woocommerce/
add_action( 'init', 'update_sku', 10, 1);
function update_sku( $sku ){
$args = array(
'post_type' => 'product',
'posts_per_page' => -1
);
$i=0;
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
$random_sku = mt_rand(100000, 999999);
update_post_meta($loop->post->ID,'_sku','');
$i++;
endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
}https://stackoverflow.com/questions/49853304
复制相似问题