Skip to content

Commit bcb8c14

Browse files
committed
MAGETWO-44584: Error "The stock item for Product in option is not valid." when adding configurable product on second website
- Fixed tests
1 parent 6f5aac8 commit bcb8c14

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

lib/internal/Magento/Framework/Search/Request/Cleaner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ private function cleanFilter($filterName)
165165
switch ($filter['type']) {
166166
case FilterInterface::TYPE_WILDCARD:
167167
case FilterInterface::TYPE_TERM:
168-
if (is_string($filter['value']) && preg_match('/\$(.+)\$/si', $filter['value'], $matches)) {
168+
if (!array_key_exists('is_bind', $filter)) {
169169
unset($this->requestData['filters'][$filterName]);
170170
}
171171
break;
172172
case FilterInterface::TYPE_RANGE:
173173
$keys = ['from', 'to'];
174174
foreach ($keys as $key) {
175-
if (isset($filter[$key]) && preg_match('/\$(.+)\$/si', $filter[$key], $matches)) {
175+
if (isset($filter[$key]) && preg_match('/^\$(.+)\$$/si', $filter[$key], $matches)) {
176176
unset($this->requestData['filters'][$filterName][$key]);
177177
}
178178
}

lib/internal/Magento/Framework/Search/Test/Unit/Adapter/Mysql/Query/Builder/MatchTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testBuildQuery()
6464
->getMock();
6565
$this->fulltextHelper->expects($this->once())
6666
->method('getMatchQuery')
67-
->with($this->equalTo(['some_field' => 'some_field']), $this->equalTo('-some_value*'))
67+
->with($this->equalTo(['some_field' => 'some_field']), $this->equalTo('-some* -value*'))
6868
->will($this->returnValue('matchedQuery'));
6969
$select->expects($this->once())
7070
->method('where')

lib/internal/Magento/Framework/Search/Test/Unit/Request/BinderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public function testBind()
5151
];
5252
$expectedResult = [
5353
'dimensions' => ['scope' => ['value' => 'default']],
54-
'queries' => ['query' => ['value' => 'match_query']],
55-
'filters' => ['filter' => ['from' => 'filter_from', 'to' => 'filter_to', 'value' => 'filter_value']],
56-
'aggregations' => ['price' => ['method' => 'filter_method']],
54+
'queries' => ['query' => ['value' => 'match_query', 'is_bind' => true]],
55+
'filters' => ['filter' => ['from' => 'filter_from', 'to' => 'filter_to', 'value' => 'filter_value', 'is_bind' => true]],
56+
'aggregations' => ['price' => ['method' => 'filter_method', 'is_bind' => true]],
5757
'from' => 1,
5858
'size' => 10,
5959
];

lib/internal/Magento/Framework/Search/Test/Unit/Request/CleanerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testClean()
4848
],
4949
'type' => 'boolQuery',
5050
],
51-
'match_query' => ['value' => 'ok', 'type' => 'matchQuery'],
51+
'match_query' => ['value' => 'ok', 'type' => 'matchQuery', 'is_bind' => true],
5252
'bool_query_rm' => [
5353
'queryReference' => [
5454
['ref' => 'match_query_rm'],
@@ -83,7 +83,7 @@ public function testClean()
8383
'filterReference' => [['ref' => 'term_filter2']],
8484
'type' => 'boolFilter',
8585
],
86-
'term_filter2' => ['value' => 'value_good', 'type' => 'termFilter'],
86+
'term_filter2' => ['value' => 'value_good', 'type' => 'termFilter', 'is_bind' => true],
8787
],
8888
];
8989
$exceptedRequestData = [
@@ -93,7 +93,7 @@ public function testClean()
9393
'queryReference' => [['ref' => 'match_query'], ['ref' => 'filtered_query_to_filter2']],
9494
'type' => 'boolQuery',
9595
],
96-
'match_query' => ['value' => 'ok', 'type' => 'matchQuery'],
96+
'match_query' => ['value' => 'ok', 'type' => 'matchQuery', 'is_bind' => true],
9797
'filtered_query_to_filter2' => [
9898
'filterReference' => [['ref' => 'bool_filter2']],
9999
'type' => 'filteredQuery',
@@ -104,7 +104,7 @@ public function testClean()
104104
'filterReference' => [['ref' => 'term_filter2']],
105105
'type' => 'boolFilter',
106106
],
107-
'term_filter2' => ['value' => 'value_good', 'type' => 'termFilter'],
107+
'term_filter2' => ['value' => 'value_good', 'type' => 'termFilter', 'is_bind' => true],
108108
],
109109
];
110110

@@ -129,7 +129,7 @@ public function testCleanWithoutAggregations()
129129
],
130130
'type' => 'boolQuery',
131131
],
132-
'match_query' => ['value' => 'ok', 'type' => 'matchQuery'],
132+
'match_query' => ['value' => 'ok', 'type' => 'matchQuery', 'is_bind' => true],
133133
'bool_query_rm' => [
134134
'queryReference' => [
135135
['ref' => 'match_query_rm'],
@@ -164,7 +164,7 @@ public function testCleanWithoutAggregations()
164164
'filterReference' => [['ref' => 'term_filter2']],
165165
'type' => 'boolFilter',
166166
],
167-
'term_filter2' => ['value' => 'value_good', 'type' => 'termFilter'],
167+
'term_filter2' => ['value' => 'value_good', 'type' => 'termFilter', 'is_bind' => true],
168168
],
169169
];
170170
$exceptedRequestData = [
@@ -174,7 +174,7 @@ public function testCleanWithoutAggregations()
174174
'queryReference' => [['ref' => 'match_query'], ['ref' => 'filtered_query_to_filter2']],
175175
'type' => 'boolQuery',
176176
],
177-
'match_query' => ['value' => 'ok', 'type' => 'matchQuery'],
177+
'match_query' => ['value' => 'ok', 'type' => 'matchQuery', 'is_bind' => true],
178178
'filtered_query_to_filter2' => [
179179
'filterReference' => [['ref' => 'bool_filter2']],
180180
'type' => 'filteredQuery',
@@ -185,7 +185,7 @@ public function testCleanWithoutAggregations()
185185
'filterReference' => [['ref' => 'term_filter2']],
186186
'type' => 'boolFilter',
187187
],
188-
'term_filter2' => ['value' => 'value_good', 'type' => 'termFilter'],
188+
'term_filter2' => ['value' => 'value_good', 'type' => 'termFilter', 'is_bind' => true],
189189
],
190190
'aggregations' => [],
191191
];

0 commit comments

Comments
 (0)