# Shopware 6.5.0 - sync api foreign key update fail

**URL:** <https://forum.shopware.com/t/shopware-6-5-0-sync-api-foreign-key-update-fail/101939>\
**Category:** Shopware 6 (English)\
**Tags:** general\
**Created:** [16. November 2023 um 12:23 UTC](https://forum.shopware.com/t/shopware-6-5-0-sync-api-foreign-key-update-fail/101939 "2023-11-16T12:23:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ipaulr94](https://avatars.discourse-cdn.com/v4/letter/i/6f9a4e/32.png) [@ipaulr94](https://forum.shopware.com/u/ipaulr94)\
**Post date:** [16. November 2023 um 12:23 UTC](https://forum.shopware.com/t/shopware-6-5-0-sync-api-foreign-key-update-fail/101939/1 "2023-11-16T12:23:53Z")

</div>

Hello. I have an extension for product price named product price type, but when I use the sync api to update the product prices and add this price type too, I get an error. The problem seems to be that in the commandqueue, getting commands in order sets the insert price type command before the insert price command.

**This is the payload** :

> [{„entity“:„product“,„payload“:[{„id“:„ed31723a61174088acec8c0c4a7d9f9d“,„productNumber“:„xxxxxxxx“,„name“:„xxxxxxxxx“,„stock“:0,„price“:[{„currencyId“:„b7d2554b0ce847cd82f3ac9bd1c0dfca“,„gross“:0.0,„net“:0.0,„linked“:false}],„manufacturer“:{„id“:„795f18243e1f4230b44f61f2ca7b7a2f“},„tax“:{„id“:„1c10ca2e9e424006a018a8821122d7d0“},„visibilities“:[{„salesChannelId“:„7a9b5ca3dfc141edbb568bf9ad97c409“,„visibility“:30}],„prices“:[{„ruleId“:„018bc91cc71f70f0995a9f96d4822550“,„type“:{„type“:„ek“},„price“:[{„currencyId“:„b7d2554b0ce847cd82f3ac9bd1c0dfca“,„gross“:96.35,„net“:80.97,„linked“:true}],„quantityStart“:1},{„ruleId“:„018bc91e2663725e96537951c3a853ea“,„type“:{„type“:„vk“},„price“:[{„currencyId“:„b7d2554b0ce847cd82f3ac9bd1c0dfca“,„gross“:109.67,„net“:92.16,„linked“:true}],„quantityStart“:0}],„ean“:„“}],„action“:„upsert“}]

**And this is the error response**

> {„errors“:[{„code“:„1452“,„status“:„500“,„title“:„Internal Server Error“,„detail“:„An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (database.product\_price\_type, CONSTRAINT fk.product\_price\_type.product\_price\_id FOREIGN KEY (product\_price\_id) REFERENCES product\_price (id) ON DELETE CASCADE ON U)“}]}

On version 6.4 this does not happen.

Thank you for your time and consideration.
