Skip to content

Commit 30383c3

Browse files
committed
MC-20636: Order Details : Order Details by Order Number
- fix static
1 parent 0ef8a7a commit 30383c3

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

app/code/Magento/SalesGraphQl/Model/Resolver/BundleOptions.php

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,14 @@ private function getBundleOptions(
9595
$bundleOptions[$bundleOptionId]['label'] = $bundleOption['label'] ?? '';
9696
$bundleOptions[$bundleOptionId]['id'] = isset($bundleOption['option_id']) ?
9797
base64_encode($bundleOption['option_id']) : null;
98-
$optionItems = $this->formatBundleOptionItems(
99-
$item,
100-
$bundleOption
101-
);
102-
$bundleOptions[$bundleOptionId]['values'] = $optionItems['items'] ?? [];
98+
if (isset($bundleOption['option_id'])) {
99+
$bundleOptions[$bundleOptionId]['values'] = $this->formatBundleOptionItems(
100+
$item,
101+
$bundleOption['option_id']
102+
);
103+
} else {
104+
$bundleOptions[$bundleOptionId]['values'] = [];
105+
}
103106
}
104107
}
105108
return $bundleOptions;
@@ -109,37 +112,35 @@ private function getBundleOptions(
109112
* Format Bundle items
110113
*
111114
* @param OrderItemInterface $item
112-
* @param array $bundleOption
115+
* @param string $bundleOptionId
113116
* @return array
114117
*/
115118
private function formatBundleOptionItems(
116119
OrderItemInterface $item,
117-
array $bundleOption
120+
string $bundleOptionId
118121
) {
119122
$optionItems = [];
120-
$optionItems['items'] = [];
121-
foreach ($bundleOption['value'] ?? [] as $bundleOptionValueKey => $bundleOptionValue) {
122-
// Find the item assign to the option
123-
/** @var OrderItemInterface $childrenOrderItem */
124-
foreach ($item->getChildrenItems() ?? [] as $childrenOrderItem) {
125-
$childOrderItemOptions = $childrenOrderItem->getProductOptions();
126-
$bundleChildAttributes = $this->serializer
127-
->unserialize($childOrderItemOptions['bundle_selection_attributes']);
128-
// Value Id is missing from parent, so we have to match the child to parent option
129-
if (isset($bundleChildAttributes['option_id'])
130-
&& $bundleChildAttributes['option_id'] == $bundleOption['option_id']) {
131-
$optionItems['items'][$childrenOrderItem->getItemId()] = [
132-
'id' => base64_encode($childrenOrderItem->getItemId()),
133-
'product_name' => $childrenOrderItem->getName(),
134-
'product_sku' => $childrenOrderItem->getSku(),
135-
'quantity' => $bundleChildAttributes['qty'],
136-
'price' => [
137-
'value' => $bundleChildAttributes['price']
138-
]
139-
];
140-
}
123+
// Find the item assign to the option
124+
/** @var OrderItemInterface $childrenOrderItem */
125+
foreach ($item->getChildrenItems() ?? [] as $childrenOrderItem) {
126+
$childOrderItemOptions = $childrenOrderItem->getProductOptions();
127+
$bundleChildAttributes = $this->serializer
128+
->unserialize($childOrderItemOptions['bundle_selection_attributes'] ?? '');
129+
// Value Id is missing from parent, so we have to match the child to parent option
130+
if (isset($bundleChildAttributes['option_id'])
131+
&& $bundleChildAttributes['option_id'] == $bundleOptionId) {
132+
$optionItems[$childrenOrderItem->getItemId()] = [
133+
'id' => base64_encode($childrenOrderItem->getItemId()),
134+
'product_name' => $childrenOrderItem->getName(),
135+
'product_sku' => $childrenOrderItem->getSku(),
136+
'quantity' => $bundleChildAttributes['qty'],
137+
'price' => [
138+
'value' => $bundleChildAttributes['price']
139+
]
140+
];
141141
}
142142
}
143+
143144
return $optionItems;
144145
}
145146
}

0 commit comments

Comments
 (0)