Skip to content

Commit 362b25a

Browse files
committed
MAGETWO-44118: Doesn't found bundle product
- Added range filter type
1 parent 5b17bd0 commit 362b25a

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
114114
$this->connection->quoteIdentifier($alias . '.' . $attribute->getAttributeCode()),
115115
$query
116116
);
117-
} elseif ($filter->getType() === FilterInterface::TYPE_TERM
118-
&& in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true)
117+
} elseif (
118+
$filter->getType() === FilterInterface::TYPE_TERM &&
119+
in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true)
119120
) {
120121
$alias = $this->tableMapper->getMappingAlias($filter);
121122
if (is_array($filter->getValue())) {
@@ -132,7 +133,10 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
132133
$alias,
133134
$value
134135
);
135-
} else {
136+
} elseif(
137+
$filter->getType() === FilterInterface::TYPE_RANGE &&
138+
in_array($attribute->getBackendType(), ['decimal', 'int'], true)
139+
) {
136140
$tableSuffix = $attribute->getBackendType() === 'decimal' ? '_decimal' : '';
137141
$table = $this->resource->getTableName("catalog_product_index_eav{$tableSuffix}");
138142
$select = $this->connection->select();
@@ -145,6 +149,31 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
145149
->where('main_table.store_id = ?', $currentStoreId)
146150
->having($query);
147151

152+
$resultQuery = 'search_index.entity_id IN (
153+
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
154+
)';
155+
} else {
156+
$table = $attribute->getBackendTable();
157+
$select = $this->connection->select();
158+
$ifNullCondition = $this->connection->getIfNullSql('current_store.value', 'main_table.value');
159+
160+
$currentStoreId = $this->scopeResolver->getScope()->getId();
161+
162+
$select->from(['main_table' => $table], 'entity_id')
163+
->joinLeft(
164+
['current_store' => $table],
165+
'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = '
166+
. $currentStoreId,
167+
null
168+
)
169+
->columns([$filter->getField() => $ifNullCondition])
170+
->where(
171+
'main_table.attribute_id = ?',
172+
$attribute->getAttributeId()
173+
)
174+
->where('main_table.store_id = ?', Store::DEFAULT_STORE_ID)
175+
->having($query);
176+
148177
$resultQuery = 'search_index.entity_id IN (
149178
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
150179
)';

0 commit comments

Comments
 (0)