Created
August 24, 2018 23:30
-
-
Save unnamedfeeling/c1d562985e80010d923e31b5642ced1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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