Commerce get product id's from order
Using the entity metadata wrapper, you could also do:

foreach (commerce_order_load_multiple(array(), array('status' =&gt; 'pending'), TRUE) as $order) {
  $product_ids = array();
  foreach (entity_metadata_wrapper('commerce_order', $order)-&gt;commerce_line_items as $delta =&gt; $line_item_wrapper) {
    if (in_array($line_item_wrapper-&gt;type-&gt;value(), commerce_product_line_item_types())) {
      $product_ids[] = $line_item_wrapper-&gt;commerce_product-&gt;raw();
    }
  }
}


The important part here is checking the type of the line item, so you don't end up including shipping line items or other types of line items in your list of product IDs. Additionally, with the wrapper notice that I used the "raw" value of the commerce_product field on the line item. This is because the "value" would be the fully loaded referenced product, while the "raw" value is simply the product ID.