@@ -114,8 +114,9 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
114
114
$ this ->connection ->quoteIdentifier ($ alias . '. ' . $ attribute ->getAttributeCode ()),
115
115
$ query
116
116
);
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 )
119
120
) {
120
121
$ alias = $ this ->tableMapper ->getMappingAlias ($ filter );
121
122
if (is_array ($ filter ->getValue ())) {
@@ -132,7 +133,10 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
132
133
$ alias ,
133
134
$ value
134
135
);
135
- } else {
136
+ } elseif (
137
+ $ filter ->getType () === FilterInterface::TYPE_RANGE &&
138
+ in_array ($ attribute ->getBackendType (), ['decimal ' , 'int ' ], true )
139
+ ) {
136
140
$ tableSuffix = $ attribute ->getBackendType () === 'decimal ' ? '_decimal ' : '' ;
137
141
$ table = $ this ->resource ->getTableName ("catalog_product_index_eav {$ tableSuffix }" );
138
142
$ select = $ this ->connection ->select ();
@@ -145,6 +149,31 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
145
149
->where ('main_table.store_id = ? ' , $ currentStoreId )
146
150
->having ($ query );
147
151
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
+
148
177
$ resultQuery = 'search_index.entity_id IN (
149
178
select entity_id from ' . $ this ->conditionManager ->wrapBrackets ($ select ) . ' as filter
150
179
) ' ;
0 commit comments