get_row('SELECT id FROM '. WPSC_TABLE_PRODUCT_CATEGORIES . ' WHERE `nice-name` = "featured" LIMIT 1', ARRAY_A); } // get random featured product if (isset($featured_category) && is_array($featured_category) && count($featured_category) > 0) { $sql = 'SELECT ' . WPSC_TABLE_PRODUCT_LIST . '.id, name, LEFT(description, 80) as description, price, pnp, file, image, special, special_price '; $sql .= 'FROM ' . WPSC_TABLE_PRODUCT_LIST . ' LEFT JOIN ' . WPSC_TABLE_ITEM_CATEGORY_ASSOC . ' ON '; $sql .= WPSC_TABLE_PRODUCT_LIST . '.id = ' . WPSC_TABLE_ITEM_CATEGORY_ASSOC . '.product_id '; $sql .= 'WHERE publish = 1 AND active = 1 AND ' . WPSC_TABLE_ITEM_CATEGORY_ASSOC . '.category_id = ' . $featured_category['id'] . ' '; if ($current_product_id != '') { $sql .= 'AND ' . WPSC_TABLE_PRODUCT_LIST . '.id != ' . $current_product_id . ' '; } $sql .= 'ORDER BY RAND() LIMIT 1'; $wpsc_query->products = $wpdb->get_results($sql, ARRAY_A); $wpsc_query->product_count = count($wpsc_query->products); } ?>