Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Feb 2007
    Location
    Santa Cruz, CA
    Posts
    14
    Plugin Contributions
    0

    Default Index page sort order is Random

    Hi all,
    On my index page, I have only 'New Products' shown. In Configuration>New Listings, I have chosen option 8, Product sort order. I have also done this in Configuration>All Listings. I have about 8 products, with sort orders like: 0, 5, 10, 15 etc. However, when I go to my store's index page:
    www.roll-over-rover.com/store
    the product list order is randomized, and changes with each refresh!
    How can I control this? Any help is really appreciated, it's driving me crazy.
    Thanks.

  2. #2
    Join Date
    Jul 2006
    Location
    Johannesburg
    Posts
    447
    Plugin Contributions
    1

    Default Re: Index page sort order is Random

    Have a look in Admin>configuration>product listing.

    More specifically at "Display Product Listing Default Sort Order"

  3. #3
    Join Date
    Feb 2007
    Location
    Santa Cruz, CA
    Posts
    14
    Plugin Contributions
    0

    Default Re: Index page sort order is Random

    Quote Originally Posted by Louis View Post
    Have a look in Admin>configuration>product listing.

    More specifically at "Display Product Listing Default Sort Order"
    I left this field blank as instructed, in order to sort by Product Sort Order, which is specified per individual product. I see in modules>new_products.php a line which reads:
    PHP Code:
    $new_products $db->ExecuteRandomMulti($new_products_queryMAX_DISPLAY_NEW_PRODUCTS); 
    Surely this is what is randomizing everything, and I see no way to turn it off. I'm wondering how I could rewrite the php to just normally execute the query.

  4. #4
    Join Date
    Jun 2008
    Posts
    1
    Plugin Contributions
    0

    Default Re: Index page sort order is Random

    Quote Originally Posted by nabrown78 View Post
    I left this field blank as instructed, in order to sort by Product Sort Order, which is specified per individual product. I see in modules>new_products.php a line which reads:
    PHP Code:
    $new_products $db->ExecuteRandomMulti($new_products_queryMAX_DISPLAY_NEW_PRODUCTS); 
    Surely this is what is randomizing everything, and I see no way to turn it off. I'm wondering how I could rewrite the php to just normally execute the query.
    nabrown, I went to Admin > Tools > Developers Tool Kit and did a search on "ExecuteRandomMulti". It brought up a list of pages, but I traced the function back to one page of interest:

    includes > classes > db > mysql > query_factory.php

    I scrolled through the function to find the php random function and found the following on line 230:

    PHP Code:
    $obj->result_random array_rand($obj->resultsizeof($obj->result)); 
    I copied and commented out the text so not to do irreparable damage, then pasted it below and edited the line to my liking. I wanted to display specific items, and since I knew there were only 9 items to display, I created my own array, using my limited knowledge of PHP and w3shools website, to list (what I assume are) the keys for the specific items in the order I wanted to display them. My code looks like the following:
    PHP Code:
    //$obj->result_random = array_rand($obj->result, sizeof($obj->result));
          
    $obj->result_random = array(1,7,4,3,5,6,2,0,8); 
    This achieved what I was looking for, so thanks for taking the first step in finding the random function. Hopefully this will help others too.

  5. #5
    Join Date
    Jul 2005
    Posts
    36
    Plugin Contributions
    0

    Default Re: Index page sort order is Random

    Thank you! it helped me a lot :-)

  6. #6
    Join Date
    Mar 2009
    Location
    India, Hyderabad
    Posts
    36
    Plugin Contributions
    1

    Default Re: Index page sort order is Random

    If any body is looking for the same solution.

    I think we needn't modify anything.

    In stead of using
    PHP Code:
    $db->ExecuteRandomMulti('sql query goes here');

    and 
    $obj->MoveNextRandom();//this is in while loop 
    we can use

    PHP Code:
    $db->Execute('sql query goes here');
    $obj->MoveNext(); //this is in while loop 
    Note :: This is only if you dont want the products or the query to product any random result.
    Regards
    Dharam

  7. #7
    Join Date
    Jun 2008
    Posts
    2
    Plugin Contributions
    0

    Default Re: Index page sort order is Random

    hi there -
    I am trying to de-randomize the new products on the index page as well but the above code didn't work for me. I have tried every sort order setting in the admin as well as changing the code to the array as mentioned above to no avail... what am I missing?
    http://showerhug.com/shop/
    thnx

  8. #8
    Join Date
    Dec 2009
    Location
    Richmond, VA
    Posts
    160
    Plugin Contributions
    3

    Default Re: Index page sort order is Random

    Soooooo to recap:

    open includes/modules/new_products.php(or featured_products.php depending on your index page)

    find:
    PHP Code:
    $db->ExecuteRandomMulti 
    and change to:
    PHP Code:
    $db->Execute 
    as dharam1987 instructed.

    this part seems to have changed a bit. next find:
    PHP Code:
    $new_products->MoveNextRandom 
    and change it to:
    PHP Code:
    $new_products->MoveNext 
    leave everything before and after intact. save/upload... and problem solved.

  9. #9
    Join Date
    Dec 2009
    Location
    Richmond, VA
    Posts
    160
    Plugin Contributions
    3

    Default Re: Index page sort order is Random

    oh and if you're changing the featured products module you will need to chage:
    PHP Code:
    [COLOR="Red"]$featured_products->MoveNextRandom[/COLOR
    to
    PHP Code:
    [COLOR="red"]$featured_products->MoveNext[/COLOR
    in the corresponding file.

    thanks guys for figuring this out.

  10. #10

    help question Re: Index page sort order is Random

    I followed the instructions above and I was able to stop the random display, but the sort order is not the way I want it.

    I have the appropriate sort order I want on each product, but for some reason it's displaying differently.

    Any thoughts?

    http://store.baseballrose.com/

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v154 Random Sort Order
    By Craig Freeburg in forum Setting Up Categories, Products, Attributes
    Replies: 11
    Last Post: 27 Aug 2015, 07:56 PM
  2. New Products Sort Order on Index Page, Question.
    By blackcap76 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 5 May 2011, 02:52 AM
  3. Change sort order in new products box on index.php page
    By jolewin in forum Customization from the Admin
    Replies: 2
    Last Post: 28 Mar 2011, 05:11 AM
  4. Sort Order Issues (items keeps rotating at random)
    By datatv in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 12 Dec 2009, 03:08 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR