Fetch products created by acting user
Hello,
I need to get products created by currently acting user and display them in a drop-down list. The code below basically works, however it displays all products created by all users. Any clues please whats wrong with my code and how to limit the list?
global $user;
$uid = $user->uid;
$products = db_query("SELECT * FROM {commerce_product} WHERE status=1 AND uid=uid");
$products_array = array();
foreach ($products as $product) {
$products_array[$product->product_id] = $product->title;
}
$form['products'] = array(
'#type' => 'select',
'#title' => t('Select Product'),
'#options' => $products_array,
);