H20hum Posted February 21, 2007 Posted February 21, 2007 Hi, Is there a straight forward way of sorting products buy price in ascending order, so cheapest first....working its way to most expensive? Thanks in advance for any help whatsoever! Craig :blink:
Guest Posted February 21, 2007 Posted February 21, 2007 for the product listings in your catalog\index.php locate this: if ($column_list[$i] == 'PRODUCT_LIST_NAME') { $HTTP_GET_VARS['sort'] = $i+1 . 'a'; $listing_sql .= " order by pd.products_name"; break; } replace it with: if ($column_list[$i] == 'PRODUCT_LIST_PRICE') { $listing_sql .= " order by final_price"; break; }
H20hum Posted February 21, 2007 Author Posted February 21, 2007 Thanks for the fast reply! Ive changed the code but my products still are not listed by price? Is there any other page other than the index.php file that I would need to change? Would I need to change any of this code? Im new to PHP, but it looks as tho its sorting by product name here. } else { $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1); $sort_order = substr($HTTP_GET_VARS['sort'], 1); $listing_sql .= ' order by '; switch ($column_list[$sort_col-1]) { case 'PRODUCT_LIST_MODEL': $listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_NAME': $listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : ''); break; case 'PRODUCT_LIST_MANUFACTURER': $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_QUANTITY': $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_IMAGE': $listing_sql .= "pd.products_name"; break; case 'PRODUCT_LIST_WEIGHT': $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_PRICE': $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; } Thanks again! :blink:
Guest Posted February 21, 2007 Posted February 21, 2007 what page is displayed in the address bar of your browser? where you want to the sorting.
H20hum Posted February 21, 2007 Author Posted February 21, 2007 The address bar is as follows: http://www.*****.co.uk/v2/index.php?cPath=41 or http://www.*****.co.uk/v2/index.php?cPath=49 The "Path=" part changes from page to page. My current site is running on the same server space so Im making changes to the new site in the V2 directory. Cheers
H20hum Posted February 21, 2007 Author Posted February 21, 2007 Sorry...I would liike all the product pages to be sorted in order of price Thanks! :'(
Guest Posted February 21, 2007 Posted February 21, 2007 well that's it. It should sort by price by default. So make sure you're updating the files on the right server. For other pages you need to find the sql queries and do the order by whatever price field is there.
H20hum Posted February 21, 2007 Author Posted February 21, 2007 Thanks for all the help...hopfully will get it working from here! ;)
Guest Posted February 27, 2007 Posted February 27, 2007 Following the help from above, I was able to get the sorting by price corrected. The only thing is I had to actually close my storefront browser and open a new browser. The sorting wouldn't correct itself by just reloading the page. My new code looks like this: if ($column_list[$i] == 'PRODUCT_LIST_PRICE') { $HTTP_GET_VARS['sort'] = $i+1 . 'a'; $listing_sql .= " order by final_price"; break;
sisteligent Posted March 28, 2007 Posted March 28, 2007 how can i sort them by price, but DESCENDENTLY ? (cheapest latest)
Guest Posted March 31, 2007 Posted March 31, 2007 you do: if ($column_list[$i] == 'PRODUCT_LIST_PRICE') { $listing_sql .= " order by final_price desc"; break; }
Pino1990 Posted April 19, 2007 Posted April 19, 2007 how can i sort them by menu facturer, then by name? I've already set to menu facturer but the "+" keep staying on productname. Take a look: http://www.edelaer.com/shop/catalog/index....cPath=27_28_183
Pino1990 Posted April 19, 2007 Posted April 19, 2007 I figured it out by myself... For the people who wants to know how: if ($column_list[$i] == 'PRODUCT_LIST_MANUFACTURER') { $HTTP_GET_VARS['sort'] = $i+1 . 'a'; $listing_sql .= " order by m.manufacturers_name, pd.products_name"; break; }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.