Skip to content

Commit 2fd73cc

Browse files
author
Nikita Chubukov
committed
MC-5906: The order of product SKU is not respected
- Fix test failures
1 parent 8bab213 commit 2fd73cc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,25 @@ public function attachConditionToCollection(
251251
$whereExpression = (string)$this->_getMappedSqlCombination($combine);
252252
if (!empty($whereExpression)) {
253253
if (!empty($combine->getConditions())) {
254+
$conditions = '';
255+
$attribute = '';
254256
foreach ($combine->getConditions() as $condition) {
255-
$conditions = $condition->getData()['value'];
256-
$attribute = $condition->getData()['attribute'];
257+
if ($condition->getData('attribute') === \Magento\Catalog\Api\Data\ProductInterface::SKU) {
258+
$conditions = $condition->getData('value');
259+
$attribute = $condition->getData('attribute');
260+
}
257261
}
258-
if (!empty($conditions)) {
262+
263+
$collection->getSelect()->where($whereExpression);
264+
265+
if (!empty($conditions) && !empty($attribute)) {
259266
$conditions = explode(',', $conditions);
260267
foreach ($conditions as &$condition) {
261268
$condition = "'" . trim($condition) . "'";
262269
}
263270
$conditions = implode(', ', $conditions);
271+
$collection->getSelect()->order("FIELD($attribute, $conditions)");
264272
}
265-
266-
$collection->getSelect()->where($whereExpression)->order("FIELD($attribute, $conditions)");
267273
} else {
268274
// Select ::where method adds braces even on empty expression
269275
$collection->getSelect()->where($whereExpression);

0 commit comments

Comments
 (0)