Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Sep 2007
    Posts
    2
    Plugin Contributions
    0

    Default Product natural order

    Hi there,

    We have helped a client setup zen cart, all is ok except for the order of products.

    The product names are numbered:
    Product 1
    Product 2
    Product 3
    etc

    When viewing a category the order is not natural
    eg 20 is before 3
    Product 1
    Product 2
    Product 20
    Product 3

    I know padding the number with 0 in front will fix it, but i don't want to do this with all products already entered.

    Is there a way to change this behaviour?

    Thanks for your help

  2. #2
    Join Date
    Feb 2007
    Location
    Leicester UK
    Posts
    219
    Plugin Contributions
    0

    Default Re: Product natural order

    Last box on the page where you enter/edit Product Information is called "Sort Order:"

    Give it a number relating the sort order you require.

  3. #3
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Product natural order

    Product 1
    Product 2
    Product 20
    Product 3

    Please remember, SQL is comparing string to string, and it is doing that by comparing character by character: P= P, e = e, ....etc, then 2 < 3, so Product 20 is before Product 3. That make sense right?
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  4. #4
    Join Date
    Nov 2006
    Location
    Dartmouth, NS Canada
    Posts
    2,378
    Plugin Contributions
    0

    Default Re: Product natural order

    Not wishing to be argumentative, but I would have to reply by saying (paraphrasing Mr. Spock) The needs of the user outweigh the needs of the programmer.

    Users are humans and count like humans and sort like humans. So any list of numbers that comes out sorted programmatically as 1, 2, 20, 3, ... is flawed, whether or not it makes sense in programming terms.

    It would be a simple matter to use a backend routine to pad out all numbers as they leave the database to some arbitrary length using zeros on the left, then sort them, then display the results without the padding. Human beans need never know this is happening. Why, after a half-century of programming, this is not standard is just one of those things best left unexamined.



    Rob

  5. #5
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Product natural order

    Exactly what I'm doing. I name my products "BR001 blah blah", "BR002 blah blah".
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  6. #6
    Join Date
    Nov 2006
    Location
    Dartmouth, NS Canada
    Posts
    2,378
    Plugin Contributions
    0

    Default Re: Product natural order

    Me too. But not everyone is as smart as we are.

    A note to the OP: Zen Cart doesn't mind if you use zeros to pad your numbers. My model numbers start with zeros where needed and they all come out fine in the wash. Unlike Excel, say, where they get stripped out by a program that insists it knows better than I what should be done.

    Rob

  7. #7
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Product natural order

    To dig in a bit, the models are stored as string, that's why you can pad all the 0 you want. If you use EasyPopulate and has Excel truncates all the leading 0, set the whole model column to text instead of number.

    G'Luck
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  8. #8
    Join Date
    Nov 2006
    Location
    Dartmouth, NS Canada
    Posts
    2,378
    Plugin Contributions
    0

    Default Re: Product natural order

    Yeah, I know. But Excel (to continue getting off topic) can be very stubborn. When I paste (or import) the whole EP file into Excel it strips out the zeros even if I preset the column to Text.

    I recently tried to use Excel to graph 3 cols of data, all of which were numbers. I wanted the first col as the x-axis labels and the other 2 as lines on the chart. Even formatting the first col as Text didn't help. Excel still drew all 3 cols as lines. I finally added a letter to each value in the first col, created the chart, then took the letter out. That worked.

    Rob

  9. #9
    Join Date
    Sep 2007
    Posts
    5
    Plugin Contributions
    0

    Default Re: Product natural order

    Speaking of the product "sort order:" field, does anyone know the name of the directory and file that does the SQL read of the product info before displaying it in the cart? I want to modify it so it reads it in "sort order:" order, or at least add some code so the products are sorted using that field. There are so many directories and progarm files it could take me all year to find it. Plus my PHP skills aren't very good.

    I had a guy modify the cart interface so it's possible that ZenCart would have used the "sort order:" field initially, but it's not now. The products come out in the cart in what seems to me to be random order. But if I can find the file that does the SQL read I can probably figure out how to modify the code to make it work the way I want.

    (In case anyone cares I'm selling online guitar lessons and it doesn't make sense to have the 300+ products sorted by name. The products appear in the correct order in the admin area but not when displayed in the cart. There are less than 90 products per category so I just use numbers from 10-99 for the values in the product "sort order:" field.)

    Thanks a million if anyone knows the answer to this. I wonder if the ZenCart book has the answer to this question?

  10. #10
    Join Date
    Sep 2007
    Posts
    2
    Plugin Contributions
    0

    Default Re: Product natural order

    OK, so I understand what all of you are saying, so I have no choice but to rename all the products and add leading 0's?

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Aberdeen Natural installation
    By Arunachala in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 31 Dec 2010, 10:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg