Skip to content

Commit 613ab57

Browse files
committed
ACP2E-780: Product Subselect Rule calculates incorrect total
- Without test
1 parent 320c2e5 commit 613ab57

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\SalesRule\Model\Rule\Condition\Product;
77

8+
use Magento\Quote\Api\Data\TotalsItemInterface;
9+
810
/**
911
* Subselect conditions for product.
1012
*/
@@ -163,9 +165,12 @@ public function validate(\Magento\Framework\Model\AbstractModel $model)
163165
}
164166
}
165167
}
168+
if ($attr !== TotalsItemInterface::KEY_BASE_ROW_TOTAL) {
169+
$childrenAttrTotal *= $item->getQty();
170+
}
166171
if ($hasValidChild || parent::validate($item)) {
167172
$total += ($hasValidChild && $useChildrenTotal && $childrenAttrTotal > 0)
168-
? $childrenAttrTotal * $item->getQty()
173+
? $childrenAttrTotal
169174
: $item->getData($attr);
170175
}
171176
}

app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/Product/SubselectTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,25 @@ public function dataProviderForFixedBundleProduct(): array
249249
],
250250
false
251251
],
252+
'validate true for bundle product data with conditions for attribute base_row_total' =>
253+
[
254+
[
255+
'id' => 'attribute_set_id',
256+
'name' => 'base_row_total',
257+
'attributeScope' => 'frontend',
258+
'attributeOperator' => '=='
259+
],
260+
[
261+
'id'=> 1,
262+
'type' => ProductType::TYPE_BUNDLE,
263+
'qty' => 2,
264+
'price' => 100,
265+
'hasChildren' => true,
266+
'baseRowTotal' => 200,
267+
'valueParsed' => 200
268+
],
269+
false
270+
],
252271
'validate true for simple product data with conditions' =>
253272
[
254273
[

0 commit comments

Comments
 (0)