shimony Posted July 21, 2010 Share Posted July 21, 2010 Hi All,i need your help please.I tried looking in this forum, but with no success.I need to keep the default sorting capabilities (the user choose how he want to sort), but i want items that are out of stock to be displayed last anyway.e.g. lets say i want to sort by price - so i would like it to be sorted by price, but still all "out of stock"items will be last.i think the idea should be to double sort:sort by choice (e.g. price) and on that sort by "in stock".Is this possible?Thank you,Eyal. Link to comment Share on other sites More sharing options...
rocky Posted July 21, 2010 Share Posted July 21, 2010 You can sort by multiple columns using MySQL. Try changing line 417 of classes/Category.php in PrestaShop v1.3.1 from: $sql .= ' ORDER BY '.(isset($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).' to: $sql .= ' ORDER BY p.`quantity` DESC, '.(isset($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).' I'm not sure whether it is right, but it should give you an idea of what to do. Link to comment Share on other sites More sharing options...
shimony Posted July 21, 2010 Author Share Posted July 21, 2010 I get blank page.I believe the place is correct, but the syntax is wrong.Any ideas? Link to comment Share on other sites More sharing options...
shimony Posted July 21, 2010 Author Share Posted July 21, 2010 okay, there was a missing ' at the end, but it doesn't work.It still show by price only. Link to comment Share on other sites More sharing options...
shimony Posted July 21, 2010 Author Share Posted July 21, 2010 On more thing, not sure it is the right way, as i need to sort by selection and if quantity is ==0 push to the end or something.Maybe we should try to reverse the order of sorting (first price and then quantity)? Link to comment Share on other sites More sharing options...
shimony Posted July 21, 2010 Author Share Posted July 21, 2010 Okay, i tried all the options and nothing works.I think there is a bypass few lines after referring to sort by price.Any other ideas? Link to comment Share on other sites More sharing options...
rocky Posted July 22, 2010 Share Posted July 22, 2010 I've updated my code above. I forgot to put p. before `quantity`. Hopefully, it will work now. Link to comment Share on other sites More sharing options...
noesac Posted July 24, 2010 Share Posted July 24, 2010 I just tried this and I don't think it worked. shimony would be interested to hear how it went for you? Link to comment Share on other sites More sharing options...
shimony Posted July 24, 2010 Author Share Posted July 24, 2010 Sorry, i didnt have the chance to test it again, i will do it only tomorrow and let you know how it went.Thanks.Eyal. Link to comment Share on other sites More sharing options...
shimony Posted July 25, 2010 Author Share Posted July 25, 2010 Well, it doesn't work.The out of stock items still shown in the same order as you asked (not at the end).I think there is a bypass there on line 423...not sure.Rocky, anyone, can you please advice?Thanks,Eyal. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now