0

How Can I load a Product from the db based on the nid?

kevinaskevin
  • 299
  • 3
  • 20
keyoke
  • 1,209
  • 12
  • 26

2 Answers2

2
$product = db_fetch_object(db_query("SELECT * FROM {uc_products} WHERE nid = '%s'", *nid here*));

print_r($product);
inazaruk
  • 74,247
  • 24
  • 188
  • 156
ykyuen
  • 36
  • 1
1

Doing a direct db call is an option; however, it is not the Drupal way and does not utilize the benefits of fields, revisions, etc that Drupal's node/CCK system offers. Since uc_products are nodes in Drupal, simply call:

$product = node_load($nid);
kevinaskevin
  • 299
  • 3
  • 20