wp_set_object_terms doesn’t work

This is the solution

function add_tags_products()
{
global $product;


$args = array(
    'post_type' => 'product', // your product post type
    'posts_per_page' => - 1,
);

$posts = get_posts($args);

foreach ($posts as $post):
    setup_postdata($post);

    // check to see if the post has any tags
    if( ! has_term( '', 'product_tag', $post->ID ) ) :
        // create the term
        wp_set_object_terms($post->ID, array('nou'), 'product_tag');
    endif;

    wp_reset_postdata();
endforeach;
}


add_action('init', 'add_tags_products');