@@ -54,11 +54,11 @@ class Builder
54
54
private $ attributeRepository ;
55
55
56
56
/**
57
- * Product collection
57
+ * EAV collection
58
58
*
59
59
* @var AbstractCollection
60
60
*/
61
- private $ productCollection ;
61
+ private $ eavCollection ;
62
62
63
63
/**
64
64
* @param ExpressionFactory $expressionFactory
@@ -148,6 +148,7 @@ protected function _getMappedSqlCondition(AbstractCondition $condition, $value =
148
148
}
149
149
150
150
$ defaultValue = 0 ;
151
+ // Check if attribute has a table with default value and add it to the query
151
152
if ($ this ->canAttributeHaveDefaultValue ($ condition ->getAttribute ())) {
152
153
$ defaultField = 'at_ ' . $ condition ->getAttribute () . '_default.value ' ;
153
154
$ defaultValue = $ this ->_connection ->quoteIdentifier ($ defaultField );
@@ -205,14 +206,14 @@ public function attachConditionToCollection(
205
206
Combine $ combine
206
207
) {
207
208
$ this ->_connection = $ collection ->getResource ()->getConnection ();
208
- $ this ->productCollection = $ collection ;
209
+ $ this ->eavCollection = $ collection ;
209
210
$ this ->_joinTablesToCollection ($ collection , $ combine );
210
211
$ whereExpression = (string )$ this ->_getMappedSqlCombination ($ combine );
211
212
if (!empty ($ whereExpression )) {
212
213
// Select ::where method adds braces even on empty expression
213
214
$ collection ->getSelect ()->where ($ whereExpression );
214
215
}
215
- $ this ->productCollection = null ;
216
+ $ this ->eavCollection = null ;
216
217
}
217
218
218
219
/**
@@ -229,8 +230,8 @@ private function canAttributeHaveDefaultValue($attributeCode)
229
230
// It's not exceptional case as we want to check if we have such attribute or not
230
231
$ attribute = null ;
231
232
}
232
- $ isNotDefaultStoreUsed = $ this ->productCollection !== null
233
- ? (int )$ this ->productCollection ->getStoreId () !== (int ) $ this ->productCollection ->getDefaultStoreId ()
233
+ $ isNotDefaultStoreUsed = $ this ->eavCollection !== null
234
+ ? (int )$ this ->eavCollection ->getStoreId () !== (int ) $ this ->eavCollection ->getDefaultStoreId ()
234
235
: false ;
235
236
236
237
return $ isNotDefaultStoreUsed && $ attribute !== null && !$ attribute ->isScopeGlobal ();
0 commit comments