Osclass Support Forums

Osclass plugin support => Cache Plugin => Topic started by: Miller on March 20, 2019, 12:46:33 PM

Title: premium ads random not working
Post by: Miller on March 20, 2019, 12:46:33 PM
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');
Title: Re: premium ads random not working
Post by: MB Themes on March 20, 2019, 12:54:03 PM
@Miller
They cannot as you want to cache :)
Title: Re: premium ads random not working
Post by: Miller on March 20, 2019, 02:58:05 PM
I want to work premium ads randomly
Title: Re: premium ads random not working
Post by: MB Themes on March 20, 2019, 03:00:02 PM
@Miller
Then disable cache, but even that I am not sure if premium loop is shuffling premium listings.