Zen Cart Logo
Forums / General Questions / Can specials be sorted?

Can specials be sorted?

Views: 4,910

Results 1 to 20 of 36
21 Jan 2007, 2:42 AM
#1
disciple avatar

disciple

Totally Zenned

Join Date:
Aug 2004
Posts:
278
Plugin Contributions:
0

Can specials be sorted?

Hi,

Is it possible to sort the specials and have them displayed in the newest special first order? If so, how would I go about doing this?

Thanks

Rick

21 Jan 2007, 4:09 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can specials be sorted?

Currently, there isn't a sort order to select on the Specials page and the Centerbox and sidebox are built from a random selection ...

You could customize these peices to sort your specials, but you don't want to lose the feature of having 9 out of 20 specials change between clicks for the customer as it is good spider food as well as good impulse shopping ... :smile:

Are you trying to sort the centerbox differently or the specials page itself?

22 Jan 2007, 2:46 PM
#3
disciple avatar

disciple

Totally Zenned

Join Date:
Aug 2004
Posts:
278
Plugin Contributions:
0

Re: Can specials be sorted?

We just want to sort the specials page itself.

Thanks

Rick

23 Jan 2007, 1:36 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can specials be sorted?

You would need to customize the sort for the Specials page:
/includes/modules/pages/specials/main_template_vars.php

NOTE: There is not an override for this file, so backup the original as well as your changes ...

The select statement currently reads:

  $specials_query_raw = "SELECT p.products_id, p.products_image, pd.products_name
                         FROM (" . TABLE_PRODUCTS . " p
                         LEFT JOIN " . TABLE_SPECIALS . " s on p.products_id = s.products_id
                         LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                         WHERE p.products_id = s.products_id and p.products_id = pd.products_id and p.products_status = '1'
                         AND s.status = 1
                         AND pd.language_id = :languagesID
                         ORDER BY s.specials_date_added DESC";

You need to alter the ORDER BY to better suit your needs ...

13 Oct 2008, 1:39 PM
#5
dranet avatar

dranet

New Zenner

Join Date:
Mar 2008
Posts:
23
Plugin Contributions:
0

Re: Can specials be sorted?

I want to do this too. If I want the Specials category on the main page to be alphabetical, how do I change this code? I tried specials_name but it didn't seem to like it much. lol Do I leave the DESC in there?

Sorry, I'm lost when it comes to coding.

Thanks!
Tracy

13 Oct 2008, 3:00 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can specials be sorted?

You would need to do the order by pd.products_name ...

13 Oct 2008, 3:04 PM
#7
dranet avatar

dranet

New Zenner

Join Date:
Mar 2008
Posts:
23
Plugin Contributions:
0

Re: Can specials be sorted?

Cool, thanks! Is there a way to sort them randomly? I sure wish I knew code!!

13 Oct 2008, 3:15 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can specials be sorted?

What is the point of sorting by name if you want them random? :unsure:

Look in the Specials Centerbox for how the specials can be sorted randomly ...

NOTE: the Specials Centerbox has a limit on how many are included that would need to be removed from the SELECT statement ...

13 Oct 2008, 3:35 PM
#9
dranet avatar

dranet

New Zenner

Join Date:
Mar 2008
Posts:
23
Plugin Contributions:
0

Re: Can specials be sorted?

Because I want to know how to do them both ways.

Thanks,
Tracy

14 Nov 2008, 4:19 AM
#10
dranet avatar

dranet

New Zenner

Join Date:
Mar 2008
Posts:
23
Plugin Contributions:
0

Re: Can specials be sorted?

Does anyone know how to sort the Specials category randomly? I'd really like to have it random.

Thanks!
Tracy

8 Jan 2009, 5:03 AM
#11
dranet avatar

dranet

New Zenner

Join Date:
Mar 2008
Posts:
23
Plugin Contributions:
0

Re: Can specials be sorted?

Random sorting of Specials? Anyone?

8 Jan 2009, 5:15 AM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can specials be sorted?

Have you peeked in the specials module for specials_index.php where it uses: ExecuteRandomMulti

You could alter the specials.php to utilize something similar with a little bit of tweaking ... :smile:

23 Jan 2009, 2:20 PM
#13
dranet avatar

dranet

New Zenner

Join Date:
Mar 2008
Posts:
23
Plugin Contributions:
0

Re: Can specials be sorted?

I have no idea how to do that. I'm not a coder. :(

Ajeh:

Have you peeked in the specials module for specials_index.php where it uses: ExecuteRandomMulti

You could alter the specials.php to utilize something similar with a little bit of tweaking ... :smile:

Are you talking about this line?

if ($specials_index_query != '') $specials_index = $db->ExecuteRandomMulti($specials_index_query, MAX_DISPLAY_SPECIAL_PRODUCTS_INDEX);

Do I paste it in the other file exactly the same way? Where is specials.php, the other guy told me to edit main_template_vars.php. Sorry, I'm really more of a hardware girl. Wires make sense, code doesn't!

Tracy

17 Mar 2010, 2:32 PM
#14
fuzziest avatar

fuzziest

New Zenner

Join Date:
Jan 2009
Posts:
12
Plugin Contributions:
0

Re: Can specials be sorted?

How do I modify the below code to sort by model number?

ORDER BY s.specials_date_added DESC";


ORDER BY s.specials_????? DESC";

Thanks

18 Mar 2010, 3:56 PM
#15
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can specials be sorted?

Seeing the whole SQL line would help to determine how to change the ORDER ...

19 Apr 2011, 7:01 AM
#16
britneycook avatar

britneycook

New Zenner

Join Date:
Oct 2010
Posts:
53
Plugin Contributions:
0

Re: Can specials be sorted?

Hi all..
Ive been trying to sort my specials page by sort_order with the following code but it keeps returning an unknown column error. My apologies, im not a programmer, but im assuming a need to define the column some how??? Please help...

$specials_query_raw = "SELECT p.products_id, p.products_image, pd.products_name,
p.master_categories_id
FROM (" . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_SPECIALS . " s on p.products_id = s.products_id
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
WHERE p.products_id = s.products_id and p.products_id = pd.products_id and p.products_status = '1'
AND s.status = 1
AND pd.language_id = :languagesID
ORDER BY sort_order, s.specials_date_added DESC";

1054 Unknown column 'sort_order' in 'order clause'
in:
[SELECT p.products_id, p.products_image, pd.products_name, p.master_categories_id FROM (zen_products p LEFT JOIN zen_specials s on p.products_id = s.products_id LEFT JOIN zen_products_description pd on p.products_id = pd.products_id ) INNER JOIN zen_categories_description cd ON (p.master_categories_id = cd.categories_id AND cd.language_id=1 AND cd.categories_description LIKE '%-###### Net 02-%') WHERE p.products_id = s.products_id and p.products_id = pd.products_id and p.products_status = '1' AND s.status = 1 AND pd.language_id = 1 ORDER BY sort_order, s.specials_date_added DESC limit 99]

19 Apr 2011, 1:47 PM
#17
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can specials be sorted?

Your error message and the SELECT that you posted do not match ...

Are you sure you are getting the SELECT from where the error is being generated? :unsure:

20 Apr 2011, 12:14 PM
#18
britneycook avatar

britneycook

New Zenner

Join Date:
Oct 2010
Posts:
53
Plugin Contributions:
0

Re: Can specials be sorted?

thats interesting..
the only change i made was to add "sort_order" to the line :
ORDER BY sort_order, s.specials_date_added DESC";
the orig was
ORDER BY s.specials_date_added DESC";

and thats the error that followed...

Ajeh:

Your error message and the SELECT that you posted do not match ...

Are you sure you are getting the SELECT from where the error is being generated? :unsure:

20 Apr 2011, 1:09 PM
#19
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can specials be sorted?

Could you go to the Tools ... Developers Tool Kit ... and in the bottom input box try a search on:
INNER JOIN

and select Catalog/Admin and click search ...

what file(s) come up?

Then a search on:
cd.categories_description

what file(s) come up?

do any contain a SELECT similar to the one you posted that displays in the error message?

If you read your SELECT statement then read the error message, you will notice there are things in the error message that are not even referenced in the SELECT ...

20 Apr 2011, 1:13 PM
#20
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can specials be sorted?

Also, you have:
sort_order

in the WHERE ... if this is from the table:
products

that should be:
p.products_sort_order

NOTE: the p is not really needed as it is unique but it helps with clarity ...

NOTE: If you added a new field to the table:
specials

for sort order, make sure that you spelled it correctly ...