Skip to content

Commit fb6620d

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-73136' into 2.3-PR-develop-1
2 parents 111a063 + 96a6321 commit fb6620d

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

app/code/Magento/SalesRule/Model/Quote/Discount.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ protected function distributeDiscount(\Magento\Quote\Model\Quote\Item\AbstractIt
179179
$roundingDelta[$key] = 0.0000001;
180180
}
181181
foreach ($item->getChildren() as $child) {
182-
$ratio = $child->getBaseRowTotal() / $parentBaseRowTotal;
182+
$ratio = $parentBaseRowTotal != 0 ? $child->getBaseRowTotal() / $parentBaseRowTotal : 0;
183183
foreach ($keys as $key) {
184184
if (!$item->hasData($key)) {
185185
continue;

app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,30 @@ public function collectItemHasChildrenDataProvider()
229229
{
230230
$data = [
231231
// 3 items, each $100, testing that discount are distributed to item correctly
232-
'three_items' => [
232+
[
233+
'child_item_data' => [
234+
'item1' => [
235+
'base_row_total' => 0,
236+
]
237+
],
238+
'parent_item_data' => [
239+
'discount_amount' => 20,
240+
'base_discount_amount' => 10,
241+
'original_discount_amount' => 40,
242+
'base_original_discount_amount' => 20,
243+
'base_row_total' => 0,
244+
],
245+
'expected_child_item_data' => [
246+
'item1' => [
247+
'discount_amount' => 0,
248+
'base_discount_amount' => 0,
249+
'original_discount_amount' => 0,
250+
'base_original_discount_amount' => 0,
251+
]
252+
],
253+
],
254+
[
255+
// 3 items, each $100, testing that discount are distributed to item correctly
233256
'child_item_data' => [
234257
'item1' => [
235258
'base_row_total' => 100,

0 commit comments

Comments
 (0)