Skip to content

Commit 37cb029

Browse files
author
Oleksii Korshenko
committed
MAGETWO-50202: [GitHub] Couldn't save shipment data #527
1 parent db3fa17 commit 37cb029

File tree

5 files changed

+6
-26
lines changed

5 files changed

+6
-26
lines changed

app/code/Magento/Sales/Model/Order/Shipment/Track.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace Magento\Sales\Model\Order\Shipment;
77

88
use Magento\Framework\Api\AttributeValueFactory;
9-
use Magento\Framework\Exception\LocalizedException;
109
use Magento\Sales\Api\Data\ShipmentTrackInterface;
1110
use Magento\Sales\Model\AbstractModel;
1211

@@ -138,16 +137,11 @@ public function setShipment(\Magento\Sales\Model\Order\Shipment $shipment)
138137
* Retrieve Shipment instance
139138
*
140139
* @return \Magento\Sales\Model\Order\Shipment
141-
* @throws \Magento\Framework\Exception\LocalizedException
142140
*/
143141
public function getShipment()
144142
{
145143
if (!$this->_shipment instanceof \Magento\Sales\Model\Order\Shipment) {
146-
if ($this->getParentId()) {
147-
$this->_shipment = $this->shipmentRepository->get($this->getParentId());
148-
} else {
149-
throw new LocalizedException(__("Parent shipment cannot be loaded for track object."));
150-
}
144+
$this->_shipment = $this->shipmentRepository->get($this->getParentId());
151145
}
152146

153147
return $this->_shipment;
@@ -214,7 +208,6 @@ public function addData(array $data)
214208
}
215209

216210
//@codeCoverageIgnoreStart
217-
218211
/**
219212
* Returns track_number
220213
*
@@ -415,6 +408,5 @@ public function setExtensionAttributes(\Magento\Sales\Api\Data\ShipmentTrackExte
415408
{
416409
return $this->_setExtensionAttributes($extensionAttributes);
417410
}
418-
419411
//@codeCoverageIgnoreEnd
420412
}

app/code/Magento/Sales/Model/ResourceModel/Order/Shipment/Relation.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ public function processRelation(\Magento\Framework\Model\AbstractModel $object)
6464
}
6565
if (null !== $object->getTracks()) {
6666
foreach ($object->getTracks() as $track) {
67-
$track->setParentId($object->getId());
6867
$this->shipmentTrackResource->save($track);
6968
}
7069
}
7170
if (null !== $object->getComments()) {
7271
foreach ($object->getComments() as $comment) {
73-
$comment->setParentId($object->getId());
7472
$this->shipmentCommentResource->save($comment);
7573
}
7674
}

app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Shipment/RelationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function setUp()
111111

112112
public function testProcessRelations()
113113
{
114-
$this->shipmentMock->expects($this->exactly(3))
114+
$this->shipmentMock->expects($this->once())
115115
->method('getId')
116116
->willReturn('shipment-id-value');
117117
$this->shipmentMock->expects($this->exactly(2))

app/code/Magento/Shipping/Test/Unit/Model/Order/TrackTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testLookup()
5252
'Magento\Shipping\Model\Order\Track',
5353
['carrierFactory' => $carrierFactory, 'shipmentRepository' => $shipmentRepository]
5454
);
55-
$model->setParentId(1);
55+
5656
$this->assertEquals('trackingInfo', $model->getNumberDetail());
5757
}
5858
}

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentCreateTest.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,11 @@ public function testInvoke()
7979
'increment_id' => null,
8080
'created_at' => null,
8181
'updated_at' => null,
82+
// 'packages' => null,
8283
'shipping_label' => null,
83-
'tracks' => [
84-
[
85-
'carrier_code' => 'UPS',
86-
'order_id' => $order->getId(),
87-
'title' => 'ground',
88-
'track_number' => '12345678'
89-
]
90-
],
84+
'tracks' => [],
9185
'items' => $items,
92-
'comments' => [
93-
[
94-
'comment' => 'Shipment-related comment.'
95-
]
96-
],
86+
'comments' => [],
9787
];
9888
$result = $this->_webApiCall($serviceInfo, ['entity' => $data]);
9989
$this->assertNotEmpty($result);

0 commit comments

Comments
 (0)