nullacht15 Posted June 16, 2005 Posted June 16, 2005 hi there, i'm searchin for a possibility to sort the product_listing with "products_date_added". can someone help me out... searchin for hours and hours now :-( thx, ren?
Guest Posted June 16, 2005 Posted June 16, 2005 It's in your index.php file and it must be changed (very carefully) here: $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'"; } } 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 pd.products_name"; break; } } } 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; You'll have to change the "order by pd.products_name" both times and you may need to call the date added in the query but I'm not certain. Give it a try without that first and see if it works. Back up your file first!
nullacht15 Posted June 16, 2005 Author Posted June 16, 2005 thx a lot. i've made a better decission ;-) just replaced all the products_quantity stuff with the products_date_added. header, text, everything. now i can sort by date also by name, price, etc. worx fine. ren?
nullacht15 Posted June 16, 2005 Author Posted June 16, 2005 a little thing is still confusing me: when i call the product_listing first time (for example by clicking a category) it always sorts "asc". how can i change these to "desc"? The Header works fine with 'a' and 'd', but the sort is always ASC :-( any idea?
Guest Posted June 16, 2005 Posted June 16, 2005 I'm sorry but I don't know the proper syntax to call for it to sort by desc by default. maybe here: $sort_order = substr($HTTP_GET_VARS['sort'], 1); and sub 0 for the 1/ Just guessing now :blush:
supirman Posted June 16, 2005 Posted June 16, 2005 a little thing is still confusing me: when i call the product_listing first time (for example by clicking a category) it always sorts "asc". how can i change these to "desc"? The Header works fine with 'a' and 'd', but the sort is always ASC :-( any idea? <{POST_SNAPBACK}> the sort isn't defined on the first request to the page, so look for this code: 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 pd.products_name"; break; } } change $listing_sql .= " order by pd.products_name"; to $listing_sql .= " order by pd.products_name desc";
nullacht15 Posted June 16, 2005 Author Posted June 16, 2005 Hi Bobby, thx a lot! Works fine now. Gr, Ren?
suppi Posted July 16, 2005 Posted July 16, 2005 hello, first sorry for my english... i?ve the same problem with order by date. so i changed the $listing_sql.= "order by pd.products_name desc"; but my problem is: the classes/split_page_result.php ignores this and when i switch to the next site, the order is still by pd.products_name. (i logged the sql statements) can someone help me? thanks
Recommended Posts
Archived
This topic is now archived and is closed to further replies.