Skip to content

Commit f158aef

Browse files
committed
AC-11925: Price is always 0 for bundle product items without dynamic price in order rest API
1 parent e7856d4 commit f158aef

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

app/code/Magento/Sales/Model/Order/Webapi/ChangeOutputArray.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -10,6 +10,7 @@
1010
use Magento\Sales\Api\Data\OrderItemInterface;
1111
use Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn;
1212
use Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer;
13+
use Magento\Bundle\Model\Product\Type;
1314

1415
/**
1516
* Class for changing row total in response.
@@ -62,7 +63,7 @@ public function execute(
6263
+ $dataObject->getBaseWeeeTaxAppliedAmount()
6364
- $dataObject->getBaseDiscountAmount());
6465

65-
return $result;
66+
return $this->getBundleProductPrice($result);
6667
}
6768

6869
/**
@@ -75,4 +76,21 @@ private function round(float $value): float
7576
{
7677
return (float) max($value, 0);
7778
}
79+
80+
/**
81+
* Get bundle product price if miss in child item
82+
*
83+
* @param array $result
84+
* @return array
85+
*/
86+
private function getBundleProductPrice(array $result): array
87+
{
88+
if ($result[OrderItemInterface::PRICE] == 0 && isset($result[OrderItemInterface::PARENT_ITEM])) {
89+
if ($result[OrderItemInterface::PARENT_ITEM][OrderItemInterface::PRODUCT_TYPE] == Type::TYPE_CODE) {
90+
$result[OrderItemInterface::PRICE] =
91+
$result[OrderItemInterface::PARENT_ITEM][OrderItemInterface::PRICE];
92+
}
93+
}
94+
return $result;
95+
}
7896
}

0 commit comments

Comments
 (0)