Skip to content

Commit

Permalink
MAGETWO-52079: [GITHUB] Order Repository GetList Method always return…
Browse files Browse the repository at this point in the history
…s the same shipping address for all orders #4019
  • Loading branch information
Mulderua committed May 4, 2016
1 parent 11baefd commit c1b7c35
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
32 changes: 23 additions & 9 deletions app/code/Magento/Sales/Model/OrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Api\SortOrder;
use Magento\Framework\App\ObjectManager;

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

/**
* @var OrderExtension
*/
private $orderExtension;

/**
* @var ShippingAssignmentBuilder
*/
private $shippingAssignmentBuilder;

/**
* OrderInterface[]
*
Expand Down Expand Up @@ -164,7 +173,7 @@ private function setShippingAssignments(OrderInterface $order)
$extensionAttributes = $order->getExtensionAttributes();

if ($extensionAttributes === null) {
$extensionAttributes = $this->getOrderExtensionDependency();
$extensionAttributes = $this->getOrderExtensionDependency()->create();
} elseif ($extensionAttributes->getShippingAssignments() !== null) {
return;
}
Expand All @@ -182,10 +191,12 @@ private function setShippingAssignments(OrderInterface $order)
*/
private function getOrderExtensionDependency()
{

return ObjectManager::getInstance()->create(
'\Magento\Sales\Api\Data\OrderExtension'
);
if (!$this->orderExtension instanceof OrderExtension) {
$this->orderExtension = \Magento\Framework\App\ObjectManager::getInstance()->get(
'\Magento\Sales\Api\Data\OrderExtensionFactory'
);
}
return $this->orderExtension;
}

/**
Expand All @@ -196,9 +207,12 @@ private function getOrderExtensionDependency()
*/
private function getShippingAssignmentBuilderDependency()
{
return ObjectManager::getInstance()->create(
'\Magento\Sales\Model\Order\ShippingAssignmentBuilder'
);
if (!$this->shippingAssignmentBuilder instanceof ShippingAssignmentBuilder) {
$this->shippingAssignmentBuilder = \Magento\Framework\App\ObjectManager::getInstance()->get(
'\Magento\Sales\Model\Order\ShippingAssignmentBuilder'
);
}
return $this->shippingAssignmentBuilder;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function testGetList()

$extensionAttributes = $this->getMock(
'\Magento\Sales\Api\Data\OrderExtension',
['getShippingAssignments'],
[],
[],
'',
false
Expand Down

0 comments on commit c1b7c35

Please sign in to comment.