File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed
app/code/Magento/Elasticsearch Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ private function getEntityStorage(array $queryResult)
59
59
{
60
60
$ ids = [];
61
61
foreach ($ queryResult ['hits ' ]['hits ' ] as $ document ) {
62
- if (!array_key_exists ('_id ' , $ document ) && array_key_exists ( ' _id ' , $ document ['fields ' ])) {
62
+ if (!array_key_exists ('_id ' , $ document ) && isset ( $ document ['fields ' ][ ' _id ' ][ 0 ])) {
63
63
$ document ['_id ' ] = $ document ['fields ' ]['_id ' ][0 ];
64
64
unset($ document ['fields ' ]);
65
65
}
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ public function create($response)
64
64
{
65
65
$ documents = [];
66
66
foreach ($ response ['documents ' ] as $ rawDocument ) {
67
- if (!array_key_exists ('_id ' , $ rawDocument ) && array_key_exists ( ' _id ' , $ rawDocument ['fields ' ])) {
67
+ if (!array_key_exists ('_id ' , $ rawDocument ) && isset ( $ rawDocument ['fields ' ][ ' _id ' ][ 0 ])) {
68
68
$ rawDocument ['_id ' ] = $ rawDocument ['fields ' ]['_id ' ][0 ];
69
69
unset($ rawDocument ['fields ' ]);
70
70
}
Original file line number Diff line number Diff line change @@ -72,8 +72,32 @@ protected function setUp(): void
72
72
public function testCreate (): void
73
73
{
74
74
$ documents = [
75
- ['title ' => 'oneTitle ' , 'description ' => 'oneDescription ' ],
76
- ['title ' => 'twoTitle ' , 'description ' => 'twoDescription ' ]
75
+ [
76
+ 'title ' => 'oneTitle ' ,
77
+ 'description ' => 'oneDescription ' ,
78
+ 'fields ' => [
79
+ '_id ' => ['1 ' ]
80
+ ]
81
+ ],
82
+ [
83
+ 'title ' => 'twoTitle ' ,
84
+ 'description ' => 'twoDescription ' ,
85
+ 'fields ' => [
86
+ '_id ' => ['2 ' ]
87
+ ]
88
+ ]
89
+ ];
90
+ $ modifiedDocuments = [
91
+ [
92
+ 'title ' => 'oneTitle ' ,
93
+ 'description ' => 'oneDescription ' ,
94
+ '_id ' => '1 '
95
+ ],
96
+ [
97
+ 'title ' => 'twoTitle ' ,
98
+ 'description ' => 'twoDescription ' ,
99
+ '_id ' => '2 '
100
+ ]
77
101
];
78
102
$ aggregations = [
79
103
'aggregation1 ' => [
@@ -113,7 +137,7 @@ public function testCreate(): void
113
137
114
138
$ this ->documentFactory
115
139
->method ('create ' )
116
- ->withConsecutive ([$ documents [0 ]], [$ documents [1 ]])
140
+ ->withConsecutive ([$ modifiedDocuments [0 ]], [$ modifiedDocuments [1 ]])
117
141
->willReturnOnConsecutiveCalls ('document1 ' , 'document2 ' );
118
142
119
143
$ this ->aggregationFactory
You can’t perform that action at this time.
0 commit comments