Skip to content

Commit 0a5c099

Browse files
committed
ACP2E-691: Order placed as logged in user has cancellation failed : Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
1 parent 0763e06 commit 0a5c099

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/code/Magento/SalesRule/Model/Coupon/Usage/Processor.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ private function updateRuleUsages(bool $isIncrement, int $ruleId): void
132132
* @param bool $isIncrement
133133
* @param int $ruleId
134134
* @param int $customerId
135+
* @throws \Exception
135136
*/
136137
private function updateCustomerRuleUsages(bool $isIncrement, int $ruleId, int $customerId): void
137138
{
@@ -144,6 +145,9 @@ private function updateCustomerRuleUsages(bool $isIncrement, int $ruleId, int $c
144145
} elseif ($isIncrement) {
145146
$ruleCustomer->setCustomerId($customerId)->setRuleId($ruleId)->setTimesUsed(1);
146147
}
147-
$ruleCustomer->save();
148+
149+
if ($ruleCustomer->hasData()) {
150+
$ruleCustomer->save();
151+
}
148152
}
149153
}

0 commit comments

Comments
 (0)