--- uc_affiliate2.module_old	2011-03-15 10:33:33.000000000 +0000
+++ uc_affiliate2.module	2011-04-09 10:59:45.000000000 +0100
@@ -346,7 +346,7 @@ function _uc_affiliate2_get_products($mo
     $values = array_merge($values, $show);
   }
 
-  $sql = "SELECT nid, title FROM {node} WHERE status = 1 $where ORDER BY title ASC";
+  $sql = "SELECT n.nid, n.title, ucp.model FROM {node} n NATURAL JOIN {uc_products} ucp WHERE n.status = 1 $where ORDER BY n.title ASC";
   
   if ($mode == 'csv') {
     $result = db_query($sql, $values);
@@ -360,8 +360,8 @@ function _uc_affiliate2_get_products($mo
   }
 
   while ($node = db_fetch_object($result)) {
-    $product_commission = uc_affiliate2_get_product_commission($user, $node->nid);
-    if ($product_commission->commission_structure == 0) {
+    $product_commission = uc_affiliate2_get_product_commission($user, $node->nid, $node->model);
+    if ($product_commission->commission_structure == 0 || $product_commission->commission_structure[0] == '0') {
       continue;
     }
     
@@ -423,7 +423,7 @@ function _uc_affiliate2_get_product_list
 
   $product_types = uc_product_types();
 
-  $result = db_query('SELECT nid, title FROM {node} WHERE status = 1 AND type IN (' . db_placeholders($product_types, 'varchar') . ') ORDER BY title ASC', $product_types);
+  $result = db_query('SELECT n.nid, n.title, ucp.model FROM {node} n NATURAL JOIN {uc_products} ucp WHERE n.status = 1 AND n.type IN (' . db_placeholders($product_types, 'varchar') . ') ORDER BY n.title ASC', $product_types);
 
   if (!$result) {
     return;
@@ -432,8 +432,8 @@ function _uc_affiliate2_get_product_list
   $products = array();
   
   while ($node = db_fetch_object($result)) {
-    $product_commission = uc_affiliate2_get_product_commission($user, $node->nid);
-    if ($product_commission->commission_structure == 0) {
+    $product_commission = uc_affiliate2_get_product_commission($user, $node->nid, $node->model);
+    if ($product_commission->commission_structure == 0 || $product_commission->commission_structure[0] == '0') {
       continue;
     }
     
