Skip to content

Commit 9cff299

Browse files
committed
MAGETWO-46720: [Github] Shipping Address not exposed for orders api #2628
- revert Order\ItemRepository.php
1 parent 95e9ea6 commit 9cff299

File tree

3 files changed

+5
-113
lines changed

3 files changed

+5
-113
lines changed

app/code/Magento/Sales/Model/Order/ItemRepository.php

Lines changed: 5 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
use Magento\Sales\Api\Data\OrderItemSearchResultInterface;
1818
use Magento\Sales\Api\Data\OrderItemSearchResultInterfaceFactory;
1919
use Magento\Sales\Api\OrderItemRepositoryInterface;
20-
use Magento\Sales\Api\Data\OrderItemExtension;
21-
use Magento\Sales\Api\Data\OrderItemExtensionInterface;
2220
use Magento\Sales\Model\ResourceModel\Metadata;
2321

2422
/**
@@ -50,17 +48,7 @@ class ItemRepository implements OrderItemRepositoryInterface
5048
/**
5149
* @var ProductOptionExtensionFactory
5250
*/
53-
protected $productOptionExtensionFactory;
54-
55-
/**
56-
* @var OrderItemExtension
57-
*/
58-
private $orderItemExtension;
59-
60-
/**
61-
* @var ShippingBuilder
62-
*/
63-
private $shippingBuilder;
51+
protected $extensionFactory;
6452

6553
/**
6654
* @var ProductOptionProcessorInterface[]
@@ -77,22 +65,22 @@ class ItemRepository implements OrderItemRepositoryInterface
7765
* @param Metadata $metadata
7866
* @param OrderItemSearchResultInterfaceFactory $searchResultFactory
7967
* @param ProductOptionFactory $productOptionFactory
80-
* @param ProductOptionExtensionFactory $productOptionExtensionFactory
68+
* @param ProductOptionExtensionFactory $extensionFactory
8169
* @param array $processorPool
8270
*/
8371
public function __construct(
8472
DataObjectFactory $objectFactory,
8573
Metadata $metadata,
8674
OrderItemSearchResultInterfaceFactory $searchResultFactory,
8775
ProductOptionFactory $productOptionFactory,
88-
ProductOptionExtensionFactory $productOptionExtensionFactory,
76+
ProductOptionExtensionFactory $extensionFactory,
8977
array $processorPool = []
9078
) {
9179
$this->objectFactory = $objectFactory;
9280
$this->metadata = $metadata;
9381
$this->searchResultFactory = $searchResultFactory;
9482
$this->productOptionFactory = $productOptionFactory;
95-
$this->productOptionExtensionFactory = $productOptionExtensionFactory;
83+
$this->extensionFactory = $extensionFactory;
9684
$this->processorPool = $processorPool;
9785
}
9886

@@ -117,7 +105,6 @@ public function get($id)
117105
}
118106

119107
$this->addProductOption($orderItem);
120-
$this->addShipping($orderItem);
121108
$this->registry[$id] = $orderItem;
122109
}
123110
return $this->registry[$id];
@@ -145,7 +132,6 @@ public function getList(SearchCriteria $searchCriteria)
145132
/** @var OrderItemInterface $orderItem */
146133
foreach ($searchResult->getItems() as $orderItem) {
147134
$this->addProductOption($orderItem);
148-
$this->addShipping($orderItem);
149135
}
150136

151137
return $searchResult;
@@ -242,7 +228,7 @@ protected function setProductOption(OrderItemInterface $orderItem, array $data)
242228

243229
$extensionAttributes = $productOption->getExtensionAttributes();
244230
if (!$extensionAttributes) {
245-
$extensionAttributes = $this->productOptionExtensionFactory->create();
231+
$extensionAttributes = $this->extensionFactory->create();
246232
$productOption->setExtensionAttributes($extensionAttributes);
247233
}
248234

@@ -282,80 +268,4 @@ protected function getBuyRequest(OrderItemInterface $entity)
282268

283269
return $request;
284270
}
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-
}
361271
}

app/code/Magento/Sales/Test/Unit/Model/Order/ItemRepositoryTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -310,21 +310,6 @@ protected function getModel(
310310
'custom_options' => $this->productOptionProcessorMock,
311311
]
312312
);
313-
$shipping = $this->getMockForAbstractClass('\Magento\Sales\Api\Data\ShippingInterface', [], '', false);
314-
$orderItemExtensionMock = $this->getMock(
315-
'\Magento\Sales\Api\Data\OrderItemExtension',
316-
['setShipping'],
317-
[],
318-
'',
319-
false
320-
);
321-
$orderItemExtensionMock->expects($this->once())->method('setShipping')->with($shipping);
322-
$model->setOrderItemExtensionDependency($orderItemExtensionMock);
323-
$shippingBuilderMock = $this->getMock('\Magento\Sales\Model\Order\ShippingBuilder', [], [], '', false);
324-
$shippingBuilderMock->expects($this->once())->method('setOrderId');
325-
$shippingBuilderMock->expects($this->once())->method('create')->willReturn($shipping);
326-
$model->setShippingBuilderDependency($shippingBuilderMock);
327-
328313
return $model;
329314
}
330315

app/code/Magento/Sales/etc/extension_attributes.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,4 @@
1010
<extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
1111
<attribute code="shipping_assignments" type="Magento\Sales\Api\Data\ShippingAssignmentInterface[]" />
1212
</extension_attributes>
13-
<extension_attributes for="Magento\Sales\Api\Data\OrderItemInterface">
14-
<attribute code="shipping" type="Magento\Sales\Api\Data\ShippingInterface" />
15-
</extension_attributes>
1613
</config>

0 commit comments

Comments
 (0)