Forums / General Questions / Auto set sort order when products out of stock?

Auto set sort order when products out of stock?

Locked

Views: 877

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
19 Mar 2010, 5:06 PM
#1
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Auto set sort order when products out of stock?

Hi All,

I use sort orders to place products in the order that I want them, however, it would be nice if before using the sort order I choose, it sent all out of stock products to the end, then all in stock products to use my specified sort orders at the front.

I read a thread where someone had done something similar, however they simply set in stock at the front and out of stock at the back.

I want the in stock items to still use the sort orders I specify and out of stock items to over-ride the sort I set to like 1000??

Anyone know how I can achieve this/done this before?

Cheers
Phil

Phil Rogers
A problem shared is a problem solved.

19 Mar 2010, 5:42 PM
#2
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Auto set sort order when products out of stock?

following the post I found, so far I have set

$listing_sql .= " order by p.products_sort_order , pd.products_name";

to

$listing_sql .= " order by p.products_sort_order , p.products_quantity desc";

in /includes/index_filters/default_filter.php

Now although this works, Here is an example why its not..

prod1 - instock - sort 0
prod2 - instock - sort 5
prod3 - outstock - sort 0
prod4 - outstock - sort 5

here is how the current set up orders them:
prod1 - instock - sort 0
prod3 - outstock - sort 0
prod2 - instock - sort 5
prod4 - outstock - sort 5

I need it to sort like this:
prod1 - instock - sort 0
prod2 - instock - sort 5
prod3 - outstock - sort 0
prod4 - outstock - sort 5

Any suggestions how to get it to do what I want??

Phil Rogers
A problem shared is a problem solved.

19 Mar 2010, 6:16 PM
#3
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Auto set sort order when products out of stock?

haha I think I worked it out

assuming im right

i've just swapped which it sorts by first..

so I now have
$listing_sql .= " order by p.products_quantity desc, p.products_sort_order";

instead of

$listing_sql .= " order by p.products_sort_order, p.products_quantity desc";

Is that right??

also can I add more rules to it?

like

name, sort, quantity..

??

Phil Rogers
A problem shared is a problem solved.