premium ads are displayed in random order in search results
after install cache plugin not working premium ads random
How to solve this?
function cust_all_premiums_ontop_random() {
$mSearch = Search::newInstance();
$query_elements = (array) json_decode($mSearch->toJson());
$mSearch->addField(sprintf("(SELECT RAND() FROM %st_item i2 WHERE %st_item.pk_i_id = i2.pk_i_id AND %st_item.b_premium = 1) AS rand_premiums", DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX));
$mSearch->order("rand_premiums DESC, " . $query_elements['order_column'], $query_elements['order_direction']);
}
osc_add_hook('search_conditions', 'cust_all_premiums_ontop_random');