Answer the question
In order to leave comments, you need to log in
Search Api and views_get_view() or views_get_view_results(), how to get field values in views?
Created a view based on the Search API index.
I'm trying to get the results of a view with fields, since we need exactly the fields of objects, limited to the output of the page specified in the arguments.
<?php$myview = views_get_view('test');
$myview->set_display('page_2');
$myview->set_current_page(1);
$myview->pre_execute();
$myview->execute();
var_dump($myview->result);
?>
[0]=>
object(stdClass)#2965 (2) {
["entity"]=>
int(1032)
["_entity_properties"]=>
array(3) {
["search_api_relevance"]=>
float(1)
["search_api_excerpt"]=>
string(0) ""
["search_api_id"]=>
string(4) "1032"
}
}
Answer the question
In order to leave comments, you need to log in
Search api view returns only entity IDs. In your case, the result is an array of objects. In each object:
'entity' - ID of your entity (nid if you search by nodes)
'_entity_properties' - an array with additional. info, the relevance value for this entity for this query, text fragments in which the search phrase was found. And "search_api_id" is the ID of the entity.
In order to get a node, it is enough to do node_load(); for each or better, collect all IDs in an array and do node_load_multiple();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question