usvi4me Posted March 12, 2010 Share Posted March 12, 2010 I would like to sort the product listing by the highest number of reviews. Explanation: Product A has one review with a 5 star rating Product B has five reviews with a 4 star rating I would like to sort them this way: Product B first (has the most reviews) Product A second Hope I'm clear. As always, any input is greatly appreciated. Link to comment Share on other sites More sharing options...
usvi4me Posted March 14, 2010 Author Share Posted March 14, 2010 I would like to sort the product listing by the highest number of reviews. Explanation: Product A has one review with a 5 star rating Product B has five reviews with a 4 star rating I would like to sort them this way: Product B first (has the most reviews) Product A second Hope I'm clear. As always, any input is greatly appreciated. What do I need to insert where in the following code to make the above happen? if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) { for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { if ($column_list[$i] == 'PRODUCT_LIST_NAME') { // $HTTP_GET_VARS['sort'] = $i+1 . 'a'; $listing_sql .= " order by products_date_added, pd.products_name"; break; Again, any help is greatly appreciated Link to comment Share on other sites More sharing options...
spooks Posted March 14, 2010 Share Posted March 14, 2010 Your wish is much more complex than you seem to realise, the product reviews are held in a seperate table with a number of entries for each product, so b4 you can do any sorting, you must go through the full list of products, find all the reviews for each of those, place that result in a new array, then sort the products by the contents of that array, then consider how you are going to deal with paging those results. Apart from the large increase in load for your server, you must consider if the result is worth all the effort. Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
usvi4me Posted March 15, 2010 Author Share Posted March 15, 2010 Your wish is much more complex than you seem to realise, the product reviews are held in a seperate table with a number of entries for each product, so b4 you can do any sorting, you must go through the full list of products, find all the reviews for each of those, place that result in a new array, then sort the products by the contents of that array, then consider how you are going to deal with paging those results. Apart from the large increase in load for your server, you must consider if the result is worth all the effort. Spooks, thanks for taking the time to respond. Disappointed to hear this is more complex then I realized. I was hoping there was a simple solution sorting via $reviews['count'] - sorted DESC. Will server load be a problem with a max of 300 items ? I am still very interested in accomplishing this. Link to comment Share on other sites More sharing options...
usvi4me Posted March 19, 2010 Author Share Posted March 19, 2010 Spooks, thanks for taking the time to respond. Disappointed to hear this is more complex then I realized. I was hoping there was a simple solution sorting via $reviews['count'] - sorted DESC. Will server load be a problem with a max of 300 items ? I am still very interested in accomplishing this. anyone feels like tackling this one Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.