If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Your Zen Cart Products / Setting Up Categories, Products, Attributes / Setting up Product Sort Order Alpha and Numeric

Setting up Product Sort Order Alpha and Numeric

Started by colinlavergne on 4 Dec 2012, 2:13 AM · Views: 940

Results 1 to 4 of 4
4 Dec 2012, 2:13 AM
#1
colinlavergne avatar

colinlavergne

New Zenner

Join Date:
Feb 2012
Posts:
7
Plugin Contributions:
0

Post #1 by colinlavergne

My product codes are a year followed by two or three letters followed by a number. For example 87LC10 tells me that this product is the 10th product recorded at a specific 1987 event. (87LC is the code for the event). However, when I put all these product codes in, ZC sorts them so that 87LC1 is followed by 87LC10 rather than 87LC2. I would like 87LC10 to follow 87LC9, not following 87LC1 as it does now.
Is there some setting I can change so that ZC will sort these product codes the way I want?

Colin

4 Dec 2012, 3:05 AM
#2
ajeh avatar

ajeh

Oba-san

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

Post #2 by ajeh

Can you use:
87LC001
87LC009
87LC010
87LC110
87LC987
87LC999

or do you need more than 3 digit on the number?

Example, for 4 digit:
87LC0001
87LC0009
87LC0010
87LC0110
87LC0987
87LC0999
87LC2999
87LC8999
87LC9999

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Dec 2012, 1:34 PM
#3
colinlavergne avatar

colinlavergne

New Zenner

Join Date:
Feb 2012
Posts:
7
Plugin Contributions:
0

Post #3 by colinlavergne

I could go back and renumber all my products, but I would rather not if there is some other way to do it. Windows Explorer on my computer manages to keep the files in correct order without having to use the renumbering trick or having to tell it to do so with some special setting so I was hoping that ZenCart would be able to do it also.

4 Dec 2012, 2:19 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #4 by gjh42

There is a PHP "natsort()" function that does this, and could probably be substituted for other sorting functions in certain places. From the PHP Manual:

asort($array1);
echo "Standard sorting\n";
print_r($array1);

natsort($array2);
echo "\nNatural order sorting\n";
print_r($array2);

Standard sorting
Array
(
[3] => img1.png
[1] => img10.png
[0] => img12.png
[2] => img2.png
)

Natural order sorting
Array
(
[3] => img1.png
[2] => img2.png
[1] => img10.png
[0] => img12.png
)