add value on last_term

This commit is contained in:
vnmedeiros 2020-06-29 11:46:22 -03:00
parent 8eefeae7be
commit 4d0e2e534a
1 changed files with 11 additions and 6 deletions

View File

@ -365,16 +365,21 @@ class Elastic_Press {
$itemsRepo = \Tainacan\Repositories\Items::get_instance(); $itemsRepo = \Tainacan\Repositories\Items::get_instance();
$items = $itemsRepo->fetch($args['items_filter'], $args['collection_id'], 'WP_Query'); $items = $itemsRepo->fetch($args['items_filter'], $args['collection_id'], 'WP_Query');
$items_aggregations = $this->last_aggregations; //if elasticPress active $items_aggregations = $this->last_aggregations; //if elasticPress active
$last_term = [];
if(isset($items_aggregations['last_term'])) {
$value = explode('.', $items_aggregations['last_term']);
$last_term = [
'value' => sizeof($value) > 1 ? $value[sizeof($value)-2] : $value[0],
'es_term' => $items_aggregations['last_term']
];
}
return [ return [
// 'total' => count($items_aggregations), // 'total' => count($items_aggregations),
// 'pages' => '0', //TODO get a total of pages // 'pages' => '0', //TODO get a total of pages
'values' => isset($items_aggregations['values']) ? $items_aggregations['values'] : [] , 'values' => isset($items_aggregations['values']) ? $items_aggregations['values'] : [],
'last_term' => isset($items_aggregations['last_term']) ? 'last_term' => $last_term
[
'label' => explode('.', $items_aggregations['last_term'])[0],
'es_term'=>$items_aggregations['last_term']
] : ''
]; ];
} }