Store loop into array

Try to replace

$id[$counter] = get_the_id();

with

array_push( $id, get_the_ID() );

to collect the post id’s into the $id array.

Update:

If you also use $ids instead of $id:

    $args = array(
        'post_type' => 'product',
        'post_status' => 'publish',
        'ignore_sticky_posts'   => 1,
        'posts_per_page' => 5,
        'orderby' => 'date',
        'order' => 'desc');
$ids = array();
$products = new WP_Query( $args );
if ( $products->have_posts() ) : 
    while ( $products->have_posts() ) : $products->the_post();
       array_push( $ids, get_the_ID() );
    endwhile;
endif;