List commerce products programatically and use them in edit form

Here is nice little snippet I use when I need to list all or some of the products from drupal commerce in select field in some forms, for example entity form.

 $query = db_select('commerce_product', 'p');
    ->fields('p', array('sku', 'title'))
    ->condition('p.type', 'giftcard', '!=');

  $result = $query->execute();

  $options = array();
  while ($record = $result->fetchAssoc()) {
    $options[$record['sku']] = $record['title'];

 $options = array('0' => t('-Any-')) + $options;  // use this only if this is used as filter of some kind

then you can go and just apply this to some form element like

  $form['some_form']['sku'] = array(
    '#type' => 'select',
    '#title' => t('Product'),
    '#default_value' => '',
    '#options' => $options,
    '#default_value' => $some_entity->sku,