magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.31k forks source link

Track not saved during shipment creation through API #13954

Closed siimm closed 4 years ago

siimm commented 6 years ago

Preconditions

  1. Magento CE 2.2.3 with sample data installed (Also same in CE 2.2.2)
  2. PHP 7.0.22

Steps to reproduce

  1. Create an order with one item
  2. Use Magento REST API to create a shipment (POST rest/V1/shipment/) Request body: { "entity":{ "order_id":3, "items": [ { "order_item_id": 3, "qty": 1 } ], "comments": [ { "is_customer_notified": 1, "comment" : "this is a comment for order #3" } ], "tracks": [ { "track_number": "2Y-987651110", "title": "United Parcel Service", "carrier_code": "ups", "order_id":3, "extension_attributes" : {} } ] } } Request with better formatting as a gist: https://gist.github.com/siimm/d4f2f6644e0d1255cbe4339bb42084e2

Expected result

  1. A shipment is created with a comment added and tracking attached

Actual result

  1. Shipment is created with comment added but without any tracking number attached

General background:

Upon saving the shipment relations in Magento\Sales\Model\ResourceModel\Order\Shipment\Relation::processRelation() $object->getTracksCollection() is consulted, while during the API request $object->setTracks() is used and it is not set as a collection

As a solution getTracks() should also be processed in Relation class, or the tacks should be added using addTarck() method on Shipping model (which initialises the collection of tracks)

magento-engcom-team commented 6 years ago

@siimm, thank you for your report. We've acknowledged the issue and added to our backlog.

arijit-de93 commented 6 years ago

I am working on this at #dmcdindia

michaelbakertup commented 5 years ago

Does anyone know if this is fixed in 2.2.6 ?

mirkocesaro commented 5 years ago

Does anyone know if this is fixed in 2.2.6 ?

@michaelbakertup the issue is still there

mam08ixo commented 5 years ago

AFAIK the preferred endpoint for creating shipments is POST /V1/order/{orderId}/ship.

m2-assistant[bot] commented 4 years ago

Hi @engcom-Alfa. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


engcom-Alfa commented 4 years ago

Hi @siimm. We are not able to reproduce this issue on fresh 2.4-develop instance. Everything works correctly.

Manual testing scenario:

  1. Create an order with one item ("order_id":1, order_item_id": 1) for ex.;
  2. Use Magento REST API to create a shipment (POST rest/V1/shipment/) Request body: { "entity":{ "order_id":3, "items": [ { "order_item_id": 3, "qty": 1 } ], "comments": [ { "is_customer_notified": 1, "comment" : "this is a comment for order #3" } ], "tracks": [ { "track_number": "2Y-987651110", "title": "United Parcel Service", "carrier_code": "ups", "order_id":3, "extension_attributes" : {} } ] } }

Actual Result: screen

A shipment is created with a comment added and tracking attached screen2

So, we have to close it. Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines if you are still facing this issue on the latest 2.4-develop branch. Thank you for collaboration.