Skip to content

Commit 1f7347f

Browse files
Merge forwardport of #11274 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/11274.patch (created by @marinagociu) based on commit(s): 1. ae9f205 2. f6121da Fixed GitHub Issues in 2.3-develop branch: - #10477: Cart price rule has failed if use dropdown attribute (reported by @minosss)
2 parents 2497062 + 7369261 commit 1f7347f

File tree

1 file changed

+17
-2
lines changed
  • app/code/Magento/SalesRule/Model/Rule/Condition/Product

1 file changed

+17
-2
lines changed

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public function asHtml()
136136
*
137137
* @param \Magento\Framework\Model\AbstractModel $model
138138
* @return bool
139+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
139140
*/
140141
public function validate(\Magento\Framework\Model\AbstractModel $model)
141142
{
@@ -145,8 +146,22 @@ public function validate(\Magento\Framework\Model\AbstractModel $model)
145146
$attr = $this->getAttribute();
146147
$total = 0;
147148
foreach ($model->getQuote()->getAllVisibleItems() as $item) {
148-
if (parent::validate($item)) {
149-
$total += $item->getData($attr);
149+
$hasValidChild = false;
150+
$useChildrenTotal = ($item->getProductType() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);
151+
$childrenAttrTotal = 0;
152+
$children = $item->getChildren();
153+
if (!empty($children)) {
154+
foreach ($children as $child) {
155+
if (parent::validate($child)) {
156+
$hasValidChild = true;
157+
if ($useChildrenTotal) {
158+
$childrenAttrTotal += $child->getData($attr);
159+
}
160+
}
161+
}
162+
}
163+
if ($hasValidChild || parent::validate($item)) {
164+
$total += (($hasValidChild && $useChildrenTotal) ? $childrenAttrTotal : $item->getData($attr));
150165
}
151166
}
152167
return $this->validateAttribute($total);

0 commit comments

Comments
 (0)