Skip to content

Commit dcd4dca

Browse files
committed
MAGETWO-52079: [GITHUB] Order Repository GetList Method always returns the same shipping address for all orders #4019
1 parent ebba9e7 commit dcd4dca

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

app/code/Magento/Sales/Model/OrderRepository.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Framework\Exception\NoSuchEntityException;
1717
use Magento\Framework\Exception\InputException;
1818
use Magento\Framework\Api\SortOrder;
19+
use Magento\Framework\App\ObjectManager;
1920

2021
/**
2122
* Repository class for @see OrderInterface
@@ -33,16 +34,6 @@ class OrderRepository implements \Magento\Sales\Api\OrderRepositoryInterface
3334
*/
3435
protected $searchResultFactory = null;
3536

36-
/**
37-
* @var OrderExtension
38-
*/
39-
private $orderExtension;
40-
41-
/**
42-
* @var ShippingAssignmentBuilder
43-
*/
44-
private $shippingAssignmentBuilder;
45-
4637
/**
4738
* OrderInterface[]
4839
*
@@ -191,12 +182,10 @@ private function setShippingAssignments(OrderInterface $order)
191182
*/
192183
private function getOrderExtensionDependency()
193184
{
194-
if (!$this->orderExtension instanceof OrderExtension) {
195-
$this->orderExtension = \Magento\Framework\App\ObjectManager::getInstance()->get(
196-
'\Magento\Sales\Api\Data\OrderExtension'
197-
);
198-
}
199-
return $this->orderExtension;
185+
186+
return ObjectManager::getInstance()->create(
187+
'\Magento\Sales\Api\Data\OrderExtension'
188+
);
200189
}
201190

202191
/**
@@ -207,12 +196,9 @@ private function getOrderExtensionDependency()
207196
*/
208197
private function getShippingAssignmentBuilderDependency()
209198
{
210-
if (!$this->shippingAssignmentBuilder instanceof ShippingAssignmentBuilder) {
211-
$this->shippingAssignmentBuilder = \Magento\Framework\App\ObjectManager::getInstance()->get(
212-
'\Magento\Sales\Model\Order\ShippingAssignmentBuilder'
213-
);
214-
}
215-
return $this->shippingAssignmentBuilder;
199+
return ObjectManager::getInstance()->create(
200+
'\Magento\Sales\Model\Order\ShippingAssignmentBuilder'
201+
);
216202
}
217203

218204
/**

app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ protected function setUp()
6464
public function testGetList()
6565
{
6666
$fieldName = 'field';
67-
$searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false);
67+
$searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false);
6868

69-
$collectionMock = $this->getMock('Magento\Sales\Model\ResourceModel\Order\Collection', [], [], '', false);
69+
$collectionMock = $this->getMock('\Magento\Sales\Model\ResourceModel\Order\Collection', [], [], '', false);
7070

7171
$filterGroupMock = $this->getMock('\Magento\Framework\Api\Search\FilterGroup', [], [], '', false);
7272
$filterGroupFilterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false);
7373
$sortOrderMock = $this->getMock('\Magento\Framework\Api\SortOrder', [], [], '', false);
74-
$itemsMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false);
74+
$itemsMock = $this->getMock('\Magento\Sales\Model\Order', ['getExtensionAttributes'], [], '', false);
7575

7676
$extensionAttributes = $this->getMock(
7777
'\Magento\Sales\Api\Data\OrderExtension',

0 commit comments

Comments
 (0)