Osclass Support Forums
Osclass theme support => Zara Osclass Responsive Theme => Topic started by: Şahin Gümüş Osmanoğlu on February 02, 2018, 09:13:07 AM
-
F.e this product name is Volvo s40, i searched volv, or volvo , doesnt match any ad. Is anybody solved this problem? :o
-
its problem coming from adding new language. If you add new language, old ads doesnt show any search
-
@Şahin
Did not hear about such language issue yet, only what I know is that search works just on titles of current user active language... so if those titles were made in english and you add and switch to german, these listings has no titles for these languages.
-
Hello
I found a solution for this problem on osclass forums.
Add this at the very bottom of your theme functions.php:
Notes:
1.- Take care not to leave blank lines after this.
2.- If your theme functions.php doesn't end with ?> skip first line of my code.
<?php
function cust_refined_pattern_search($params) {
if (@$params['sPattern'] != '') {
$mSearch = Search::newInstance();
$query_elements = (array) json_decode($mSearch->toJson());
$mSearch->addLocale('%');
$mSearch->addGroupBy(DB_TABLE_PREFIX.'t_item.pk_i_id');
if (@$params['sOrder'] != 'i_price') {
$mSearch->addJoinTable(count($query_elements['tables_join']), sprintf("(SELECT fk_i_item_id, MATCH(s_title, s_description) AGAINST('%s') AS relevance FROM %st_item_description) des", $params['sPattern'], DB_TABLE_PREFIX), 'des.fk_i_item_id = '.DB_TABLE_PREFIX.'t_item.pk_i_id', 'INNER' );
$mSearch->order("des.relevance DESC, dt_pub_date", "DESC");
}
}
}
osc_add_hook('search_conditions', 'cust_refined_pattern_search');
function cust_alerts_user_dashboard() {
if (Params::getParam('page') == "user" && Params::getParam('action') == "alerts") {
$webUser = new CWebUser;
$aAlerts = Alerts::newInstance()->findByUser( Session::newInstance()->_get('userId'), false );
$user = User::newInstance()->findByPrimaryKey( Session::newInstance()->_get('userId'));
foreach($aAlerts as $k => $a) {
$array_conditions = (array)json_decode($a['s_search']);
$search = new Search();
$search->setJsonAlert($array_conditions);
if (osc_version() > 361) $search->notFromUser(Session::newInstance()->_get('userId'));
$search->addLocale('%');
$search->addGroupBy(DB_TABLE_PREFIX.'t_item.pk_i_id');
$search->limit(0, 3);
$aAlerts[$k]['items'] = $search->doSearch();
}
$webUser->_exportVariableToView('alerts', $aAlerts);
View::newInstance()->_reset('alerts');
$webUser->_exportVariableToView('user', $user);
}
}
osc_add_hook('before_html', 'cust_alerts_user_dashboard');
?>
Works exactly as I want. Hope it helps someone.
cheers
-
Hello
I found a solution for this problem on forums.osclass.org:
https://forums.osclass.org/3-5-x/search-problem-oc-3-5-3/msg113711/#msg113711
Add this at the very bottom of your theme functions.php:
Notes:
1.- Take care not to leave blank lines after this.
2.- If your theme functions.php doesn't end with ?> skip first line of my code.
<?php
function cust_refined_pattern_search($params) {
if (@$params['sPattern'] != '') {
$mSearch = Search::newInstance();
$query_elements = (array) json_decode($mSearch->toJson());
$mSearch->addLocale('%');
$mSearch->addGroupBy(DB_TABLE_PREFIX.'t_item.pk_i_id');
if (@$params['sOrder'] != 'i_price') {
$mSearch->addJoinTable(count($query_elements['tables_join']), sprintf("(SELECT fk_i_item_id, MATCH(s_title, s_description) AGAINST('%s') AS relevance FROM %st_item_description) des", $params['sPattern'], DB_TABLE_PREFIX), 'des.fk_i_item_id = '.DB_TABLE_PREFIX.'t_item.pk_i_id', 'INNER' );
$mSearch->order("des.relevance DESC, dt_pub_date", "DESC");
}
}
}
osc_add_hook('search_conditions', 'cust_refined_pattern_search');
function cust_alerts_user_dashboard() {
if (Params::getParam('page') == "user" && Params::getParam('action') == "alerts") {
$webUser = new CWebUser;
$aAlerts = Alerts::newInstance()->findByUser( Session::newInstance()->_get('userId'), false );
$user = User::newInstance()->findByPrimaryKey( Session::newInstance()->_get('userId'));
foreach($aAlerts as $k => $a) {
$array_conditions = (array)json_decode($a['s_search']);
$search = new Search();
$search->setJsonAlert($array_conditions);
if (osc_version() > 361) $search->notFromUser(Session::newInstance()->_get('userId'));
$search->addLocale('%');
$search->addGroupBy(DB_TABLE_PREFIX.'t_item.pk_i_id');
$search->limit(0, 3);
$aAlerts[$k]['items'] = $search->doSearch();
}
$webUser->_exportVariableToView('alerts', $aAlerts);
View::newInstance()->_reset('alerts');
$webUser->_exportVariableToView('user', $user);
}
}
osc_add_hook('before_html', 'cust_alerts_user_dashboard');
?>
Works exactly as I want. Hope it helps someone.
cheers
How install? Need run hook?
-
Lift this theard up, its still a problem.