Skip to content

Commit 1c94eaf

Browse files
committed
MAGETWO-75526: Products Rule based on a attribute value does not display products in the front-end
- Add comment; - Rename property;
1 parent abd95d0 commit 1c94eaf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app/code/Magento/Rule/Model/Condition/Sql/Builder.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class Builder
5454
private $attributeRepository;
5555

5656
/**
57-
* Product collection
57+
* EAV collection
5858
*
5959
* @var AbstractCollection
6060
*/
61-
private $productCollection;
61+
private $eavCollection;
6262

6363
/**
6464
* @param ExpressionFactory $expressionFactory
@@ -148,6 +148,7 @@ protected function _getMappedSqlCondition(AbstractCondition $condition, $value =
148148
}
149149

150150
$defaultValue = 0;
151+
// Check if attribute has a table with default value and add it to the query
151152
if ($this->canAttributeHaveDefaultValue($condition->getAttribute())) {
152153
$defaultField = 'at_' . $condition->getAttribute() . '_default.value';
153154
$defaultValue = $this->_connection->quoteIdentifier($defaultField);
@@ -205,14 +206,14 @@ public function attachConditionToCollection(
205206
Combine $combine
206207
) {
207208
$this->_connection = $collection->getResource()->getConnection();
208-
$this->productCollection = $collection;
209+
$this->eavCollection = $collection;
209210
$this->_joinTablesToCollection($collection, $combine);
210211
$whereExpression = (string)$this->_getMappedSqlCombination($combine);
211212
if (!empty($whereExpression)) {
212213
// Select ::where method adds braces even on empty expression
213214
$collection->getSelect()->where($whereExpression);
214215
}
215-
$this->productCollection = null;
216+
$this->eavCollection = null;
216217
}
217218

218219
/**
@@ -229,8 +230,8 @@ private function canAttributeHaveDefaultValue($attributeCode)
229230
// It's not exceptional case as we want to check if we have such attribute or not
230231
$attribute = null;
231232
}
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()
234235
: false;
235236

236237
return $isNotDefaultStoreUsed && $attribute !== null && !$attribute->isScopeGlobal();

0 commit comments

Comments
 (0)