I want to order search result by its metadata, for example "price"
how to do this ?
this is the original function in search_hooks.php,
function search_objects_hook($hook, $type, $value, $params) {
$db_prefix = elgg_get_config('dbprefix');
$join = "JOIN {$db_prefix}objects_entity oe ON e.guid = oe.guid";
$params['joins'] = array($join);
$fields = array('title', 'description');$where = search_get_where_sql('oe', $fields, $params);
$params['wheres'] = array($where);
$params['count'] = TRUE;
$count = elgg_get_entities($params);
// no need to continue if nothing here.
if (!$count) {
return array('entities' => array(), 'count' => $count);
}
$params['count'] = FALSE;
$params['order_by'] = search_get_order_by_sql('e', 'oe', $params['sort'], $params['order']);
$params['preload_owners'] = true;
$entities = elgg_get_entities($params);// add the volatile data for why these entities have been returned.
foreach ($entities as $entity) {
$title = search_get_highlighted_relevant_substrings($entity->title, $params['query']);
$entity->setVolatileData('search_matched_title', $title);$desc = search_get_highlighted_relevant_substrings($entity->description, $params['query']);
$entity->setVolatileData('search_matched_description', $desc);
}return array(
'entities' => $entities,
'count' => $count,
);
}
what should i change if i want to order by entity "price" ?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- Avicena AlGhiffar Alsharaawy@AVicenaGhifa
Avicena AlGhiffar Alsharaawy - 0 likes
You must log in to post replies.Something like this:
thanks , it works , thank you