@@ -107,21 +107,23 @@ private function processAttributesInfo(array $attributesInfo): array
107
107
public function getBundleOptions (\Magento \Sales \Api \Data \OrderItemInterface $ item ): array
108
108
{
109
109
$ bundleOptions = [];
110
- if ($ item instanceof \Magento \Sales \Model \Order \Item) {
111
- $ options = $ item ->getProductOptions ();
112
- } else {
113
- $ options = $ item ->getOrderItem ()->getProductOptions ();
114
- }
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 );
110
+ if ($ item ->getProductType () === 'bundle ' ) {
111
+ if ($ item instanceof \Magento \Sales \Model \Order \Item) {
112
+ $ options = $ item ->getProductOptions ();
113
+ } else {
114
+ $ options = $ item ->getOrderItem ()->getProductOptions ();
115
+ }
116
+ if (isset ($ options ['bundle_options ' ])) {
117
+ //$bundleOptions = $this->serializer->unserialize($options['bundle_options']);
118
+ foreach ($ options ['bundle_options ' ] as $ bundleOptionKey => $ bundleOption ) {
119
+ $ bundleOptions [$ bundleOptionKey ]['items ' ] = $ bundleOption ['value ' ] ?? [];
120
+ $ bundleOptions [$ bundleOptionKey ]['label ' ] = $ bundleOption ['label ' ];
121
+ foreach ($ bundleOptions [$ bundleOptionKey ]['items ' ] as $ bundleOptionValueKey => $ bundleOptionValue ) {
122
+ $ bundleOptions [$ bundleOptionKey ]['items ' ][$ bundleOptionValueKey ]['product_sku ' ] = $ bundleOptionValue ['title ' ];
123
+ $ bundleOptions [$ bundleOptionKey ]['items ' ][$ bundleOptionValueKey ]['product_name ' ] = $ bundleOptionValue ['title ' ];
124
+ $ bundleOptions [$ bundleOptionKey ]['items ' ][$ bundleOptionValueKey ]['quantity_ordered ' ] = $ bundleOptionValue ['qty ' ];
125
+ $ bundleOptions [$ bundleOptionKey ]['items ' ][$ bundleOptionValueKey ]['id ' ] = base64_encode ((string )$ bundleOptionValueKey );
126
+ }
125
127
}
126
128
}
127
129
}
0 commit comments