CaptainKaos Posted March 13, 2018 Share Posted March 13, 2018 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 Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 13, 2018 Share Posted March 13, 2018 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 Quote Link to comment Share on other sites More sharing options...
CaptainKaos Posted March 13, 2018 Author Share Posted March 13, 2018 MrB like always you are a legend Ill pad , thats works for me Thank You Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.