17
17
use Magento \Sales \Api \Data \OrderItemSearchResultInterface ;
18
18
use Magento \Sales \Api \Data \OrderItemSearchResultInterfaceFactory ;
19
19
use Magento \Sales \Api \OrderItemRepositoryInterface ;
20
- use Magento \Sales \Api \Data \OrderItemExtension ;
21
- use Magento \Sales \Api \Data \OrderItemExtensionInterface ;
22
20
use Magento \Sales \Model \ResourceModel \Metadata ;
23
21
24
22
/**
@@ -50,17 +48,7 @@ class ItemRepository implements OrderItemRepositoryInterface
50
48
/**
51
49
* @var ProductOptionExtensionFactory
52
50
*/
53
- protected $ productOptionExtensionFactory ;
54
-
55
- /**
56
- * @var OrderItemExtension
57
- */
58
- private $ orderItemExtension ;
59
-
60
- /**
61
- * @var ShippingBuilder
62
- */
63
- private $ shippingBuilder ;
51
+ protected $ extensionFactory ;
64
52
65
53
/**
66
54
* @var ProductOptionProcessorInterface[]
@@ -77,22 +65,22 @@ class ItemRepository implements OrderItemRepositoryInterface
77
65
* @param Metadata $metadata
78
66
* @param OrderItemSearchResultInterfaceFactory $searchResultFactory
79
67
* @param ProductOptionFactory $productOptionFactory
80
- * @param ProductOptionExtensionFactory $productOptionExtensionFactory
68
+ * @param ProductOptionExtensionFactory $extensionFactory
81
69
* @param array $processorPool
82
70
*/
83
71
public function __construct (
84
72
DataObjectFactory $ objectFactory ,
85
73
Metadata $ metadata ,
86
74
OrderItemSearchResultInterfaceFactory $ searchResultFactory ,
87
75
ProductOptionFactory $ productOptionFactory ,
88
- ProductOptionExtensionFactory $ productOptionExtensionFactory ,
76
+ ProductOptionExtensionFactory $ extensionFactory ,
89
77
array $ processorPool = []
90
78
) {
91
79
$ this ->objectFactory = $ objectFactory ;
92
80
$ this ->metadata = $ metadata ;
93
81
$ this ->searchResultFactory = $ searchResultFactory ;
94
82
$ this ->productOptionFactory = $ productOptionFactory ;
95
- $ this ->productOptionExtensionFactory = $ productOptionExtensionFactory ;
83
+ $ this ->extensionFactory = $ extensionFactory ;
96
84
$ this ->processorPool = $ processorPool ;
97
85
}
98
86
@@ -117,7 +105,6 @@ public function get($id)
117
105
}
118
106
119
107
$ this ->addProductOption ($ orderItem );
120
- $ this ->addShipping ($ orderItem );
121
108
$ this ->registry [$ id ] = $ orderItem ;
122
109
}
123
110
return $ this ->registry [$ id ];
@@ -145,7 +132,6 @@ public function getList(SearchCriteria $searchCriteria)
145
132
/** @var OrderItemInterface $orderItem */
146
133
foreach ($ searchResult ->getItems () as $ orderItem ) {
147
134
$ this ->addProductOption ($ orderItem );
148
- $ this ->addShipping ($ orderItem );
149
135
}
150
136
151
137
return $ searchResult ;
@@ -242,7 +228,7 @@ protected function setProductOption(OrderItemInterface $orderItem, array $data)
242
228
243
229
$ extensionAttributes = $ productOption ->getExtensionAttributes ();
244
230
if (!$ extensionAttributes ) {
245
- $ extensionAttributes = $ this ->productOptionExtensionFactory ->create ();
231
+ $ extensionAttributes = $ this ->extensionFactory ->create ();
246
232
$ productOption ->setExtensionAttributes ($ extensionAttributes );
247
233
}
248
234
@@ -282,80 +268,4 @@ protected function getBuyRequest(OrderItemInterface $entity)
282
268
283
269
return $ request ;
284
270
}
285
-
286
- /**
287
- * Sets shipping address to quote item as extension attribute
288
- *
289
- * @param OrderItemInterface $orderItem
290
- * @return void
291
- */
292
- private function addShipping (OrderItemInterface $ orderItem )
293
- {
294
- /** @var OrderItemExtensionInterface $extensionAttributes */
295
- $ extensionAttributes = $ orderItem ->getExtensionAttributes ();
296
- if ($ extensionAttributes === null ) {
297
- $ extensionAttributes = $ this ->getOrderItemExtensionDependency ();
298
- }
299
- /** @var ShippingBuilder $shipping */
300
- $ shipping = $ this ->getShippingBuilderDependency ();
301
- $ shipping ->setOrderId ($ orderItem ->getOrderId ());
302
- $ extensionAttributes ->setShipping ($ shipping ->create ());
303
- $ orderItem ->setExtensionAttributes ($ extensionAttributes );
304
- }
305
-
306
- /**
307
- * Get the new OrderItemExtension dependency for application code
308
- *
309
- * @return OrderItemExtension
310
- * @deprecated
311
- */
312
- private function getOrderItemExtensionDependency ()
313
- {
314
- if (!$ this ->orderItemExtension instanceof OrderItemExtension) {
315
- $ this ->orderItemExtension = \Magento \Framework \App \ObjectManager::getInstance ()->get (
316
- '\Magento\Sales\Api\Data\OrderItemExtension '
317
- );
318
- }
319
- return $ this ->orderItemExtension ;
320
- }
321
-
322
- /**
323
- * The setter function to inject the mocked dependency during unit test
324
- *
325
- * @param OrderItemExtension $orderItemExtension
326
- * @return void
327
- * @deprecated
328
- */
329
- public function setOrderItemExtensionDependency (OrderItemExtension $ orderItemExtension )
330
- {
331
- $ this ->orderItemExtension = $ orderItemExtension ;
332
- }
333
-
334
- /**
335
- * Get the new ShippingBuilder dependency for application code
336
- *
337
- * @return \Magento\Sales\Model\Order\ShippingBuilder
338
- * @deprecated
339
- */
340
- private function getShippingBuilderDependency ()
341
- {
342
- if (!$ this ->shippingBuilder instanceof \Magento \Sales \Model \Order \ShippingBuilder) {
343
- $ this ->shippingBuilder = \Magento \Framework \App \ObjectManager::getInstance ()->get (
344
- '\Magento\Sales\Model\Order\ShippingBuilder '
345
- );
346
- }
347
- return $ this ->shippingBuilder ;
348
- }
349
-
350
- /**
351
- * The setter function to inject the mocked dependency during unit test
352
- *
353
- * @param \Magento\Sales\Model\Order\ShippingBuilder shippingBuilder
354
- * @return void
355
- * @deprecated
356
- */
357
- public function setShippingBuilderDependency (\Magento \Sales \Model \Order \ShippingBuilder $ shippingBuilder )
358
- {
359
- $ this ->shippingBuilder = $ shippingBuilder ;
360
- }
361
271
}
0 commit comments