Skip to content

Commit d6a414d

Browse files
committed
ACP2E-1348: Catalog price rule is applied only to the first product from the conditions with list of SKUs
1 parent 9c42b97 commit d6a414d

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public function loadArray($arr)
516516
) ? $this->_localeFormat->getNumber(
517517
$arr['is_value_parsed']
518518
) : false;
519-
} elseif (!empty($arr['operator']) && $arr['operator'] == '()') {
519+
} elseif (!empty($arr['operator']) && in_array($arr['operator'], ['()', '!()', true])) {
520520
if (isset($arr['value'])) {
521521
$arr['value'] = preg_replace('/\s*,\s*/', ',', $arr['value']);
522522
}

dev/tests/integration/testsuite/Magento/CatalogRule/Model/ResourceModel/Product/ConditionsToCollectionApplierTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,22 @@ private function conditionProvider()
433433
'simple-product-13',
434434
]
435435
],
436+
437+
// test filter by multiple sku and "is not one of" condition
438+
'variation 23' => [
439+
'condition' => $this->getConditionsForVariation23(),
440+
'expected-sku' => [
441+
'simple-product-3',
442+
'simple-product-4',
443+
'simple-product-6',
444+
'simple-product-7',
445+
'simple-product-8',
446+
'simple-product-9',
447+
'simple-product-11',
448+
'simple-product-12',
449+
'simple-product-13',
450+
]
451+
],
436452
];
437453
}
438454

@@ -1058,6 +1074,25 @@ private function getConditionsForVariation22()
10581074
return $this->getCombineConditionFromArray($conditions);
10591075
}
10601076

1077+
private function getConditionsForVariation23()
1078+
{
1079+
$conditions = [
1080+
'type' => \Magento\CatalogRule\Model\Rule\Condition\Combine::class,
1081+
'aggregator' => 'all',
1082+
'value' => 1,
1083+
'conditions' => [
1084+
[
1085+
'type' => \Magento\CatalogRule\Model\Rule\Condition\Product::class,
1086+
'operator' => '!()',
1087+
'value' => 'simple-product-1, simple-product-2, simple-product-5, simple-product-10',
1088+
'attribute' => 'sku'
1089+
]
1090+
]
1091+
];
1092+
1093+
return $this->getCombineConditionFromArray($conditions);
1094+
}
1095+
10611096
private function getCombineConditionFromArray(array $data)
10621097
{
10631098
$combinedCondition = $this->combinedConditionFactory->create();

0 commit comments

Comments
 (0)