Jump to content

Numbering Order / Product Order


Recommended Posts

What am i not getting here ???


Settings / Layout / layout settings 

Im using the UPC Code field to number and sort products, but doing weird stuff  

eg: all use ASC

1 to 99 works 

1 to 101 fails

100 and 101 come first then starts at 1 to 99  

if you guys are doing some weird logic what is it ill just work with that 

Link to comment
Share on other sites

Let's check something first. In admin, Store Settings, Advanced tab, set Debugging Mode to Enabled. Then, enter your IP address in the adjacent field. (www.whatismyip.com)

Call up a page of products. At the bottom of the page is a grey area that lists all the SQL queries made. There will be one that should have ORDER BY UPC ASC as part of the query.

This tells us that indeed the database records are coming in sorted in that way.

The column type that holds the UPC code is VARCHAR - a textual type. So, the sort will be alphanumerical:
1, 10, 100, 101, 2, 20, 200, 201, etc

(Which does not explain why 100, 101, 1 is the order you see.)

What is desirable is a "Natural Sort" on text columns of data that look like numbers, but MySQL does not have that capability.

There are work-arounds but these solutions assume you are actually creating your own SQL statements - not something CubeCart is coded to allow one to do.

I think your best solution to sorting on UPC (or GTIN, ISBN, etc in text-type table columns) is to pad the values with zeroes:
0000000001, 0000000002, 0000000003, 0000000010, 00000000020, etc


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...