get list of product line item in rule php
This is a good way to get them

$line_items = $commerce_order-&gt;commerce_line_items['und'];
 foreach($line_items as $lid) {
 $line_item = commerce_line_item_load($lid['line_item_id']);
$pid[] = $line_item-&gt;data['context']['product_ids'][0];
//also you  can load products
//  $product =  commerce_product_load($pid);
 }