Skip to content

Commit 6b09675

Browse files
committed
MAGETWO-44573: API model load does not trigger corresponding events in Sales Module
1 parent 4197d0e commit 6b09675

File tree

9 files changed

+9
-23
lines changed

9 files changed

+9
-23
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ public function get($id)
6060

6161
if (!isset($this->registry[$id])) {
6262
/** @var \Magento\Sales\Api\Data\OrderAddressInterface $entity */
63-
$entity = $this->metadata->getNewInstance();
64-
65-
$this->metadata->getMapper()->load($entity, $id);
66-
63+
$entity = $this->metadata->getNewInstance()->load($id);
6764
if (!$entity->getEntityId()) {
6865
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
6966
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ public function get($id)
6464
}
6565
if (!isset($this->registry[$id])) {
6666
/** @var \Magento\Sales\Api\Data\CreditmemoInterface $entity */
67-
$entity = $this->metadata->getNewInstance();
68-
$this->metadata->getMapper()->load($entity, $id);
67+
$entity = $this->metadata->getNewInstance()->load($id);
6968
if (!$entity->getEntityId()) {
7069
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
7170
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public function get($id)
6262
}
6363
if (!isset($this->registry[$id])) {
6464
/** @var \Magento\Sales\Api\Data\InvoiceInterface $entity */
65-
$entity = $this->metadata->getNewInstance();
66-
$this->metadata->getMapper()->load($entity, $id);
65+
$entity = $this->metadata->getNewInstance()->load($id);
6766
if (!$entity->getEntityId()) {
6867
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
6968
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ public function get($id)
9999
}
100100
if (!isset($this->registry[$id])) {
101101
/** @var OrderItemInterface $orderItem */
102-
$orderItem = $this->metadata->getNewInstance();
103-
$this->metadata->getMapper()->load($orderItem, $id);
102+
$orderItem = $this->metadata->getNewInstance()->load($id);
104103
if (!$orderItem->getItemId()) {
105104
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
106105
}

app/code/Magento/Sales/Model/Order/Payment/Repository.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ public function get($id)
7979
throw new \Magento\Framework\Exception\InputException(__('ID required'));
8080
}
8181
if (!isset($this->registry[$id])) {
82-
$entity = $this->metaData->getNewInstance();
83-
$this->metaData->getMapper()->load($entity, $id);
82+
$entity = $this->metaData->getNewInstance()->load($id);
8483
if (!$entity->getId()) {
8584
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
8685
}

app/code/Magento/Sales/Model/Order/Payment/Transaction/Repository.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ public function get($id)
9595
throw new \Magento\Framework\Exception\InputException(__('ID required'));
9696
}
9797
if (!$this->entityStorage->has($id)) {
98-
$entity = $this->metaData->getNewInstance();
99-
/** @var \Magento\Sales\Api\Data\TransactionInterface $entity */
100-
$this->metaData->getMapper()->load($entity, $id);
98+
$entity = $this->metaData->getNewInstance()->load($id);
10199
if (!$entity->getTransactionId()) {
102100
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
103101
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ public function get($id)
6060

6161
if (!isset($this->registry[$id])) {
6262
/** @var \Magento\Sales\Api\Data\ShipmentInterface $entity */
63-
$entity = $this->metadata->getNewInstance();
64-
65-
$this->metadata->getMapper()->load($entity, $id);
66-
63+
$entity = $this->metadata->getNewInstance()->load($id);
6764
if (!$entity->getEntityId()) {
6865
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
6966
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public function get($id)
6060
}
6161
if (!isset($this->registry[$id])) {
6262
/** @var \Magento\Sales\Api\Data\OrderInterface $entity */
63-
$entity = $this->metadata->getNewInstance();
64-
$this->metadata->getMapper()->load($entity, $id);
63+
$entity = $this->metadata->getNewInstance()->load($id);
6564
if (!$entity->getEntityId()) {
6665
throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
6766
}

lib/internal/Magento/Framework/ObjectManager/Code/Generator/Persistor.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@ protected function _getGetConnectionMethod()
249249
*/
250250
protected function _getLoadEntityMethod()
251251
{
252-
$body = "\$entity = \$this->{$this->_getSourceFactoryPropertyName()}->create();\n"
253-
. "\$this->{$this->_getSourceResourcePropertyName()}->load(\$entity, \$key);\n"
252+
$body = "\$entity = \$this->{$this->_getSourceFactoryPropertyName()}->create()->load(\$key);\n"
254253
. "return \$entity;";
255254
return [
256255
'name' => 'loadEntity',

0 commit comments

Comments
 (0)