Jump to content

need to double sort - by choice and anyway put "sold out" items last.


Recommended Posts

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...