Index: uc_upsell_core.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_upsell/uc_upsell_core.inc,v
retrieving revision 1.1.2.31
diff -u -p -r1.1.2.31 uc_upsell_core.inc
--- uc_upsell_core.inc	3 Jan 2010 21:18:04 -0000	1.1.2.31
+++ uc_upsell_core.inc	19 Jun 2010 03:18:47 -0000
@@ -146,7 +146,7 @@ function uc_upsell_get_associate_nids($s
   $sought = array(); // Capture found nid
   $related = array(); // Final related array
   $related_by_term = array(); // Any nodes related by taxonomy we happen to find.
-  
+
   foreach ($source as $nid) {
     if ((is_object($nid) && $nid->nid) || (is_array($nid) && $nid['nid'])) $nid = (is_object($nid)) ? $nid->nid : $nid['nid'];
 
@@ -181,7 +181,7 @@ function uc_upsell_get_associate_nids($s
 
   // First, if we are including related-by-taxonomy nodes, and an array exists, only include as many as needed.
   if (count($related_by_term) > 0 && count($related) < $max) {
-  
+
     $needed = $max - count($related); // How many do we need?
 
     if ($needed > 0) {
@@ -198,21 +198,27 @@ function uc_upsell_get_associate_nids($s
   $ary = array_unique($ary);
 
   // If count of related nodes doesn't meet threshold and can include random nodes, add them.
-  
-  /*** Notes: This code should be moved into its own method, since it's "context agnostic." 
-     - Should find a way to honor the product types settings (it currently does not) ****/
-  
+  // TODO: This code should be moved into its own method, since it's "context agnostic."
   if (count($ary) < $max && $vars['use_random']) {
 
     $random_nids = array();
     $filter_query = implode(",", array_merge($ary, uc_upsell_get_cart_nids()));
 
-    $randoms = db_query("SELECT `nid`
-                FROM {node}
-                WHERE `status` = 1
-                AND `type` IN ('". implode("','", uc_product_product_types()) ."')
-                AND NOT nid IN (". $filter_query .")
-                ORDER BY RAND()");
+    if ($filter_query) {
+      $randoms = db_query("SELECT `nid`
+                  FROM {node}
+                  WHERE `status` = 1
+                  AND `type` IN ('". implode("','", $config['global']['types']) ."')
+                  AND NOT nid IN (". $filter_query .")
+                  ORDER BY RAND()");
+    }
+    else {
+      $randoms = db_query("SELECT `nid`
+                  FROM {node}
+                  WHERE `status` = 1
+                  AND `type` IN ('". implode("','", $config['global']['types']) ."')
+                  ORDER BY RAND()");
+    }
 
     while ($random = db_fetch_array($randoms)) {
       $random_nids[] = $random['nid'];
@@ -224,7 +230,7 @@ function uc_upsell_get_associate_nids($s
 
     $ary = array_unique(array_merge($ary, array_slice($random_nids, 0, $max - count($ary))));
   }
-  
+
   // Allow other modules to alter associate array
   drupal_alter('uc_upsell_related', $ary);
 
