Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save unnamedfeeling/c1d562985e80010d923e31b5642ced1a to your computer and use it in GitHub Desktop.
Save unnamedfeeling/c1d562985e80010d923e31b5642ced1a to your computer and use it in GitHub Desktop.
<?php
$target_products = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page'=>-1
);
$my_query = new WP_Query( $target_products );
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post();
$term_taxonomy_ids = wp_set_object_terms( get_the_ID(), 'main', 'pa_sklad', true );
$thedata = ['pa_sklad'=>[
'name'=>'pa_sklad',
'value'=>'main',
'is_visible' => '1',
'is_taxonomy' => '1'
]];
update_post_meta( get_the_ID(),'_product_attributes',$thedata);
echo 'Updated product - '.$post->post_title.PHP_EOL.'<br>';
endwhile;
}
wp_reset_query();
die();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment