duderino3 Posted August 24, 2013 Posted August 24, 2013 Dear Oscommercler. I´ve got a question for my sort of the specials in my shop http://www.tt-shop-jesumann.de classically oscommerce do ot via order by special date added. now i want to do it like in this shop http://schoeler-mick...457021e746c3789 there the customer has the opinion to sort it like he wants How i have to change my file specials.php or is there already an addon for this problem? <?php $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC"; $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS); many thanks
MrPhil Posted August 25, 2013 Posted August 25, 2013 Is that an osC-based shop? Are you talking about "sort by title/price ascending/descending"? It looks like all they do is put up a selection list, and onchange (Javascript) they fetch a new page from the server, with a different sort order specified (not local Javascript, not AJAX, not jQuery). Right now the osC sort is by date-added-descending, so it certainly would be possible to do such a thing, assuming that the title and price are available in that database query. You could even sort on multiple criteria, such as by price ascending (cheapest to most expensive) and then (secondarily) date added descending (newest to oldest within a price). Have you looked in the add-ons library to see if someone has already implemented something like this? It would take two changes to osC: 1) to add the sort selection list and (re-)request the page with a specified sort order, and 2) as a URL query string accept a sort order (default: s.specials_date_added DESC) and use that in the query. It's not trivial, but it ain't rocket science either (be sure to sanitize the query string, and check its content, rather than simply using whatever the page passed in). In this day and age, someone doing this would probably implement it client-side as pure Javascript (that's common for table headers with a sort up/down button), or use AJAX or jQuery to request new data without refreshing the whole page. Doing it purely client-side with Javascript means that you have to send over all the products on special, so the data is available to sort, even if you only display the first N items.
burt Posted August 25, 2013 Posted August 25, 2013 You can make the specials page use the product_listing module which then gives you some different sorting options automatically. See http://www.oscommerce.com/forums/topic/393668-product-listing-proposal/#entry1675345 for a download of the special page set up to use this idea.
duderino3 Posted August 26, 2013 Author Posted August 26, 2013 thanks for your replies. it should be something like this, but i need it only for the specials.php and i use oscommerce 2.3.1 the shop from schoeler-micke isn´t an oscommerce shop and i do also think that they use a javascript or something. maybe there is something for 2.3.1 from this thread. http://www.oscommerce.com/forums/topic/356489-sort-products-by-dropdown-add-on/ thanks
MrPhil Posted August 27, 2013 Posted August 27, 2013 The only JS they appear to be using is to go to a "different" page (same page, different sort criteria) when making a selection from the drop-down sort list. osC would have to have that sort list added to the page, plus pass a sort parameter back to the page (currently, the sort order is fixed by date-added).
Recommended Posts
Archived
This topic is now archived and is closed to further replies.