File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed
app/code/Magento/Elasticsearch/SearchAdapter/Aggregation/Builder
lib/internal/Magento/Framework/Search/Dynamic/Algorithm Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -46,8 +46,7 @@ public function build(
46
46
/** @var DynamicBucket $bucket */
47
47
$ algorithm = $ this ->algorithmRepository ->get ($ bucket ->getMethod (), ['dataProvider ' => $ dataProvider ]);
48
48
$ data = $ algorithm ->getItems ($ bucket , $ dimensions , $ this ->getEntityStorage ($ queryResult ));
49
- $ stats = $ queryResult ['aggregations ' ][$ bucket ->getName ()] ?? [];
50
- return $ this ->prepareData ($ data , $ stats );
49
+ return $ this ->prepareData ($ data );
51
50
}
52
51
53
52
/**
@@ -74,17 +73,12 @@ private function getEntityStorage(array $queryResult)
74
73
* Prepare result data
75
74
*
76
75
* @param array $data
77
- * @param array $stats
78
76
* @return array
79
77
*/
80
- private function prepareData (array $ data, array $ stats ): array
78
+ private function prepareData ($ data)
81
79
{
82
80
$ resultData = [];
83
- foreach ($ data as $ key => $ value ) {
84
- if (!isset ($ data [$ key +1 ])) {
85
- $ value ['to ' ] = !isset ($ stats ['max ' ]) ? $ value ['to ' ] : $ stats ['max ' ];
86
- $ value ['to ' ] += 0.01 ;
87
- }
81
+ foreach ($ data as $ value ) {
88
82
$ rangeName = "{$ value ['from ' ]}_ {$ value ['to ' ]}" ;
89
83
$ value ['value ' ] = $ rangeName ;
90
84
$ resultData [$ rangeName ] = $ value ;
Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ public function getItems(
49
49
$ dbRanges = $ this ->processRange ($ dbRanges , $ options ['max_intervals_number ' ]);
50
50
$ data = $ this ->dataProvider ->prepareData ($ range , $ dbRanges );
51
51
52
+ $ aggregations = $ this ->dataProvider ->getAggregations ($ entityStorage );
53
+ if ($ aggregations ['max ' ]) {
54
+ $ data [array_key_last ($ data )]['to ' ] = $ aggregations ['max ' ] + 0.01 ;
55
+ }
56
+
52
57
return $ data ;
53
58
}
54
59
You can’t perform that action at this time.
0 commit comments