Skip to content

Commit ea590a4

Browse files
committed
MC-20636: Order Details :: Order Details by Order Number
- simulate the item for value option selection
1 parent c92e70e commit ea590a4

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

app/code/Magento/SalesGraphQl/Model/Resolver/OrderItem/DataProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ private function fetch()
129129
/** @var OrderInterface $associatedOrder */
130130
$associatedOrder = $orderList[$orderItem->getOrderId()];
131131
$itemOptions = $this->optionsProcessor->getItemOptions($orderItem);
132+
$bundleOptions = $orderItem->getProductType() === 'bundle' ?
133+
$this->optionsProcessor->getBundleOptions($orderItem) : [];
134+
$bundleOptions1 = $orderItem->getProductType() === 'bundle' ?
135+
$this->optionsProcessor->getBundleOptions($orderItem) : [];
132136

133137
$this->orderItemList[$orderItem->getItemId()] = [
134138
'id' => base64_encode($orderItem->getItemId()),
@@ -150,6 +154,8 @@ private function fetch()
150154
'quantity_invoiced' => $orderItem->getQtyInvoiced(),
151155
'quantity_canceled' => $orderItem->getQtyCanceled(),
152156
'quantity_returned' => $orderItem->getQtyReturned(),
157+
'bundle_options' => $orderItem->getProductType() === 'bundle' ?
158+
$this->optionsProcessor->getBundleOptions($orderItem) : [],
153159
];
154160

155161
}

app/code/Magento/SalesGraphQl/Model/Resolver/OrderItem/OptionsProcessor.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,31 @@ private function processAttributesInfo(array $attributesInfo): array
100100
}
101101

102102
/**
103-
* TODO: use this method for bundle options
104103
*
105-
* @param mixed $item
106-
* @return mixed|null
104+
* @param \Magento\Sales\Api\Data\OrderItemInterface $item
105+
* @return array
107106
*/
108-
public function getSelectionAttributes($item)
107+
public function getBundleOptions(\Magento\Sales\Api\Data\OrderItemInterface $item): array
109108
{
109+
$bundleOptions = [];
110110
if ($item instanceof \Magento\Sales\Model\Order\Item) {
111111
$options = $item->getProductOptions();
112112
} else {
113113
$options = $item->getOrderItem()->getProductOptions();
114114
}
115-
if (isset($options['bundle_selection_attributes'])) {
116-
return $this->serializer->unserialize($options['bundle_selection_attributes']);
115+
if (isset($options['bundle_options'])) {
116+
//$bundleOptions = $this->serializer->unserialize($options['bundle_options']);
117+
foreach ($options['bundle_options'] as $bundleOptionKey => $bundleOption) {
118+
$bundleOptions[$bundleOptionKey]['values'] = $bundleOption['value'] ?? [];
119+
$bundleOptions[$bundleOptionKey]['label'] = $bundleOption['label'];
120+
foreach ($bundleOptions[$bundleOptionKey]['values'] as $bundleOptionValueKey => $bundleOptionValue) {
121+
$bundleOptions[$bundleOptionKey]['values'][$bundleOptionValueKey]['product_sku'] = $bundleOptionValue['title'];
122+
$bundleOptions[$bundleOptionKey]['values'][$bundleOptionValueKey]['product_name'] = $bundleOptionValue['title'];
123+
$bundleOptions[$bundleOptionKey]['values'][$bundleOptionValueKey]['quantity_ordered'] = $bundleOptionValue['qty'];
124+
$bundleOptions[$bundleOptionKey]['values'][$bundleOptionValueKey]['id'] = base64_encode((string)$bundleOptionValueKey);
125+
}
126+
}
117127
}
118-
return null;
128+
return $bundleOptions;
119129
}
120130
}

0 commit comments

Comments
 (0)