Originally Posted by
nabrown78
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_query, MAX_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->result, sizeof($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.
Bookmarks