Skip to content

Commit c8aebbd

Browse files
committed
ACP2E-2376: avoid double calculation for configurable and child product while applying discount for configurable
1 parent 15ea8fd commit c8aebbd

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

app/code/Magento/SalesRule/Model/Validator.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -479,13 +479,7 @@ public function initTotals($items, Address $address)
479479

480480
/** @var Quote\Item $item */
481481
foreach ($items as $item) {
482-
if ($item->getHasChildren()) {
483-
continue;
484-
}
485-
if (!$this->isValidItemForRule($item, $rule)
486-
|| ($item->getChildren() && $item->isChildrenCalculated())
487-
|| $item->getNoDiscount()
488-
) {
482+
if (!$this->isValidItemForRule($item, $rule)) {
489483
continue;
490484
}
491485
$qty = $this->validatorUtility->getItemQty($item, $rule);
@@ -517,6 +511,18 @@ public function initTotals($items, Address $address)
517511
*/
518512
private function isValidItemForRule(AbstractItem $item, Rule $rule)
519513
{
514+
if ($item->getParentItem() || $item->getParentItemId()) {
515+
return false;
516+
}
517+
518+
if (($item->getHasChildren() || $item->getChildren()) && $item->isChildrenCalculated()) {
519+
return false;
520+
}
521+
522+
if ($item->getNoDiscount()) {
523+
return false;
524+
}
525+
520526
if (!$rule->getActions()->validate($item)) {
521527
return false;
522528
}

0 commit comments

Comments
 (0)