*

BabyDunk

  • ****
  • 161 posts
[Help] will this conflict with "improve search for premium"
« on: August 19, 2016, 03:11:30 AM »
Hello Frosticek

can you look over this and see if it will conflict with the "improve search for premium" function in backoffice manager ?

Code: [Select]
<?php
//Add Username search function to the search engine
function cust_search_keyword_wildcard_with_user_username($params) {

    if (
$params['sPattern']) {
        
$mSearch =  Search::newInstance();
        
$query_elements = (array) json_decode($mSearch->toJson());
        
$pattern $query_elements['sPattern'];


        
$mSearch->setJsonAlert($query_elements);

        
// Search by user.Username too
        
$mSearch->addJoinTable(count($query_elements['tables_join']), DB_TABLE_PREFIX."t_user u""fk_i_user_id = u.pk_i_id"'INNER');
        
        
$aPattern explode(' '$pattern);
        
$userNameCond '';

        foreach (
$aPattern as $word) {
            if (
$word$userNameCond .= sprintf(" || u.s_username = '%s'"$word);
        }

        
$mSearch->addConditions("1 = 1 " $userNameCond);
        
$mSearch->addGroupBy(DB_TABLE_PREFIX.'t_item.pk_i_id');
    }
}

osc_add_hook('search_conditions''cust_search_keyword_wildcard_with_user_username'1);
?>



teseo made it and it works very well although i removed apart of the function. its was throwing up to many off topic listings from what the search term was.

this is what i removed as i presume i need the rest
Code: [Select]
$query_elements['sPattern'] = str_replace(' ', '* ', $pattern) . '*';

Thanks in Advance and i big thank you to Teseo he's another master lol ;)
Chris
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

MB Themes

Re: [Help] will this conflict with "improve search for premium"
« Reply #1 on: August 19, 2016, 08:30:22 AM »
@BabyDunk
That function in backoffice manager does change default ordering to be ordered by premium, then by date (default is by date).
As there is no order function in your code, if everything is good, it should not cause troubles.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

BabyDunk

  • ****
  • 161 posts
Re: [Help] will this conflict with "improve search for premium"
« Reply #2 on: August 19, 2016, 11:07:48 AM »
Thank you  ;)
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D