Dirty Butter Posted December 22, 2016 Share Posted December 22, 2016 My Sort works with listings in a Category. But it does not work in either the Search box or Advanced Search results page. Changing the default in Admin effects Category as it should, but has no effect on Search results. What files should I check to debug this? My Search is NOT stock, but rather code provided by @bsmither. As far as I know nothing to do with sort has been edited, however. Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 22, 2016 Share Posted December 22, 2016 I think this is a known issue. Same with not being able to sort on Sale Items. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted December 22, 2016 Author Share Posted December 22, 2016 Thanks! I had misunderstood - thought only the On Sale item sort was being addressed in GitHub. Quote Link to comment Share on other sites More sharing options...
jasehead Posted December 27, 2016 Share Posted December 27, 2016 I tried raising this as an issue six months ago but was beaten down: https://github.com/cubecart/v6/issues/1162 You can have any colour you like, so long as it's black. Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 27, 2016 Share Posted December 27, 2016 Please experiment with this small edit: In the skin template box.search.php, find near line 22 (for Foundation): <input type="hidden" name="_a" value="category"> On a new blank line after that, add: <input type="hidden" name="sort[{$CONFIG.product_sort_column}]" value="{$CONFIG.product_sort_direction}"> This adds a sort parameter to the querystring that is according to the Store Settings. The Quick Search box uses the GET method when submitting that form. When showing a list of results, the sorter is suppose to show how the list is sorted - if the sorted method is one of up to five defined methods. (Store Settings is potentially unlimited.) If the method shown is not one of the defined methods, the sorter is supposed to show "--Please Select--", but it doesn't. That's because the "--Please Select--" option is listed as the first option (that's good), it is disabled and can't be selected (that's good), and all other options do not have the 'selected' attribute (that's to be expected). But with these conditions, browsers will generally show as default the first 'viable' choice (not good). So, to indicate that the results list is not sorted by the (implied) indicated method, we need to force the browser to show "--Please Select--". In the skin template content.category.php, find near line 45 (for Foundation): <select name="sort" id="product_sort"> <option value="" disabled>{$LANG.form.please_select}</option> Change to: <select name="sort" id="product_sort"> <option value="" disabled selected>{$LANG.form.please_select}</option> You may ask, then what happens when one of the defined sort methods gets the 'selected' attribute? That means two options have the 'selected' attribute. Technically, this is illegal (HTML may not 'validate'). True, although I have not tried this with every known browser, at least Firefox will show the last option with the 'selected' attribute in the drop-down selector. I figured a way around that, if anyone needs their HTML to validate. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted December 27, 2016 Author Share Posted December 27, 2016 I get a page refresh when I change the Sort, but the list order does not change - that happens no matter which sort method I choose. Your edits did not help my situation. Here's the url after the page refreshes: https://dirtybutter.com/plushcatalog/search.html?_a=category&search[keywords]=CARTERS%20BLUE%20DOG&sort[date_added]=ASC Â Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 27, 2016 Share Posted December 27, 2016 Sorry. I was responding to @jasehead who hijacked your conversation, in solving Issue #1162 in the Github. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted December 27, 2016 Author Share Posted December 27, 2016 I've been known to hijack a few threads myself lol. np The CC demo store creates the same url I get, but their sort works. I tried to enable debugging in the Demo admin, but it's evidently not allowed, as I get a blank page. So I created another demo store TV product so I would have something to sort on the demo store. Then I watched the waterfall. I just barely understand how to use the waterfall, but I couldn't see anything obviously different in my waterfall results on my store Sort and on the Demo store sort. MY Search (that you created) uses the meta_keywords instead of the description. Would that be the reason mine doesn't work? Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 28, 2016 Share Posted December 28, 2016 The waterfall will not reveal how CubeCart processes (or ignores, or overrules) the sort parameters given to it. To find out why YOUR searchCatalogue() function is not sorting on search results as one would expect, we would need to peek at the function's execution. Send me an email with a copy of your catalogue.class.php file. Â Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted December 28, 2016 Author Share Posted December 28, 2016 Email sent - THANKS! Quote Link to comment Share on other sites More sharing options...
bsandall Posted December 28, 2016 Share Posted December 28, 2016 'Sort by' wasn't working properly, but that was fixed (see here). Note also that search results are always sorted by relevance on the first page load - the admin product listing order setting is used when browsing the store categories, not for search results. You can change that behavior by removing the following lines from your `searchCatalogue` method: // starting on line 1618 using the most recent CubeCart code from GitHub: } elseif ($search_mode == 'fulltext') { $order['field'] = 'Relevance'; $order['sort'] = 'DESC'; } // leave this closing brace That will then default to the store setting for sorting search results. Of course, if you have a substantially modified version of that file, you will have to wait for bhsmither's assistance. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted December 29, 2016 Author Share Posted December 29, 2016 Thanks to Bsmither for finding the part of my edited code that was not allowing sort to work properly!! Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 29, 2016 Share Posted December 29, 2016 Actually, the fault is in the published code. An issue was posted in the Github. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.