Zen Cart has a genral bug, which is radom new prodout listing in home page or in other page is not really random
for example if u have 3000 NEW products, let say the id is 1 to 3000, then the function that use to random (ExecuteRandomMulti()) will random get a id from 3000 NEW product,
after that, if u go to admin to set the home page new product display limit is 9, then home page will take 9 product from database.
However, if u check the id of the product, u will find the product id will be squence, such as 1001, 1002 ....1009
that mean the funtion will random get 1 id and squence take the rest.
there is someone to fix this problem, change some coding in ExecuteRandomMulti(), then it really random take the id each time.
But, there is a bug too, if u have not enough product or ur prodout is out of date, not new product anymore, it will display the same product in the list
for example, a product might be display 2 time in the list
Can Any one solve this or have a better solution?
below is the function code after change
note: the function can find in /includes/classes/db/mysql/query_factor.php
function ExecuteRandomMulti2($zf_sql, $zf_limit = 0, $zf_cache = false, $zf_cachetime=0) {
$this->zf_sql = $zf_sql;
$time_start = explode(' ', microtime());
$obj = new queryFactoryResult;
$obj->result = array();
if (!$this->db_connected) $this->set_error('0', DB_ERROR_NOT_CONNECTED);
$zp_db_resource = @mysql_query($zf_sql, $this->link);
if (!$zp_db_resource) $this->set_error(mysql_errno(),mysql_error());
$obj->resource = $zp_db_resource;
$obj->cursor = 0;
$obj->Limit = $zf_limit;
if ($obj->RecordCount() > 0 && $zf_limit > 0) {
$obj->EOF = false;
$zp_Start_row = 0;
if ($zf_limit) {
$zp_start_row = zen_rand(0, $obj->RecordCount() - 1);
}
$obj->Move($zp_start_row);
$obj->Limit = $zf_limit;
$zp_ii = 0;
while (!$obj->EOF) {
$zp_random_row = zen_rand(0, $obj->RecordCount() - 1);
mysql_data_seek($zp_db_resource, $zp_random_row);
$zp_result_array = @mysql_fetch_array($zp_db_resource);
if ($zp_ii == $zf_limit) $obj->EOF = true;
if ($zp_result_array) {
while (list($key, $value) = each($zp_result_array)) {
$obj->result[$zp_ii][$key] = $value;
}
} else {.......................



