File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed
app/code/Magento/SalesGraphQl/Model/Resolver/OrderItem Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,10 @@ private function fetch()
129
129
/** @var OrderInterface $associatedOrder */
130
130
$ associatedOrder = $ orderList [$ orderItem ->getOrderId ()];
131
131
$ 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 ) : [];
132
136
133
137
$ this ->orderItemList [$ orderItem ->getItemId ()] = [
134
138
'id ' => base64_encode ($ orderItem ->getItemId ()),
@@ -150,6 +154,8 @@ private function fetch()
150
154
'quantity_invoiced ' => $ orderItem ->getQtyInvoiced (),
151
155
'quantity_canceled ' => $ orderItem ->getQtyCanceled (),
152
156
'quantity_returned ' => $ orderItem ->getQtyReturned (),
157
+ 'bundle_options ' => $ orderItem ->getProductType () === 'bundle ' ?
158
+ $ this ->optionsProcessor ->getBundleOptions ($ orderItem ) : [],
153
159
];
154
160
155
161
}
Original file line number Diff line number Diff line change @@ -100,21 +100,31 @@ private function processAttributesInfo(array $attributesInfo): array
100
100
}
101
101
102
102
/**
103
- * TODO: use this method for bundle options
104
103
*
105
- * @param mixed $item
106
- * @return mixed|null
104
+ * @param \Magento\Sales\Api\Data\OrderItemInterface $item
105
+ * @return array
107
106
*/
108
- public function getSelectionAttributes ( $ item )
107
+ public function getBundleOptions ( \ Magento \ Sales \ Api \ Data \ OrderItemInterface $ item ): array
109
108
{
109
+ $ bundleOptions = [];
110
110
if ($ item instanceof \Magento \Sales \Model \Order \Item) {
111
111
$ options = $ item ->getProductOptions ();
112
112
} else {
113
113
$ options = $ item ->getOrderItem ()->getProductOptions ();
114
114
}
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
+ }
117
127
}
118
- return null ;
128
+ return $ bundleOptions ;
119
129
}
120
130
}
You can’t perform that action at this time.
0 commit comments