更改视图搜索api solr结果

时间:2016-10-05 06:30:09

标签: drupal drupal-7 drupal-commerce

我正在使用搜索api和Solr,当我回显结果变量时,它给了我以下结果

stdClass Object
(
    [entity] => 442415
    [_entity_properties] => Array
    (
    [search_api_relevance] => 1
    [search_api_excerpt] =>
    [search_api_item_id] => 442415
    )

)

在我添加的视图中(自定义文本字段,即全局变量),使用此nid 442415,我将执行某些节点加载操作,最后, 我会得到特定产品的价格。此代码块将在foreach中执行。 _views_pre_render

请指导,

我应该使用哪个钩子,_views_post_execute或_views_pre_render? 如何为哪个变量分配新值以及如何在tpl

中打印它

最后,我想显示每个项目的价格

1 个答案:

答案 0 :(得分:1)

UWP MapControl: MapElement fixed heading解决了我的问题。

解决方法

function mymodule_views_pre_render(&$view) {
  if($view->name == 'my_view') {
    foreach($view->result as &$row) {
        $row->_entity_properties['nothing'] = 'new value';
    }
  }
}

<强>视图视场 - 视图 - 名称 - 显示名称 - nothing.tpl.php

 print $row->_entity_properties['nothing']; 
相关问题