# How to safely update custom fields (keeping other custom field values)?

**URL:** <https://forum.shopware.com/t/how-to-safely-update-custom-fields-keeping-other-custom-field-values/72893>\
**Category:** Programming (EN)\
**Created:** [18. Februar 2021 um 20:11 UTC](https://forum.shopware.com/t/how-to-safely-update-custom-fields-keeping-other-custom-field-values/72893 "2021-02-18T20:11:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![riddla](https://avatars.discourse-cdn.com/v4/letter/r/a88e4f/32.png) [@riddla](https://forum.shopware.com/u/riddla)\
**Post date:** [18. Februar 2021 um 20:11 UTC](https://forum.shopware.com/t/how-to-safely-update-custom-fields-keeping-other-custom-field-values/72893/1 "2021-02-18T20:11:27Z")

</div>

We are updating some products custom fields via the&nbsp;`productRepository`s&nbsp;`upsert`&nbsp;method:

```
 $productdata = [// ... 'customFields' =\> ['productLine' =\> 'foo', 'setConsists' =\> 'bar'] // ... ];$this-\>productRepository-\>upsert( [$productdata], \Shopware\Core\Framework\Context::createDefaultContext() );

```

Will other custom field values be deleted when updating the product like this (which is my current assumption tracking down a nasty bug)?

---

<div class="post-metadata">

**Author:** ![Shopwarian](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shopwarian/32/12844_2.png) [@Shopwarian](https://forum.shopware.com/u/Shopwarian)\
**Post date:** [28. Februar 2021 um 09:55 UTC](https://forum.shopware.com/t/how-to-safely-update-custom-fields-keeping-other-custom-field-values/72893/2 "2021-02-28T09:55:24Z")

</div>

No, other custom fields data will not be affected by this. Only those, that you specifically mention (in your case productLine and setConsists), get changed.
