akeneo / pim-community-dev

[Community Development Repository] The open source Product Information Management (PIM)
http://www.akeneo.com
Other
954 stars 514 forks source link

API: Unexpected update behavoir of existing product's values #6100

Closed pardahlman closed 7 years ago

pardahlman commented 7 years ago

Hello again 🙂 ,

Still running Akeneo PIM 1.7 CE akeneo-pim-system-info_2017-04-23_17-21.txt

I have an existing product with two attributes. I use the update/create a product API endpoint to update the product. The updated product's values only contains one of the two attribute. The request is accepted and the API returns 204 No Content. When looking at the product, the value of the provided attribute is updated (✔️ expected), but the omitted attribute is still present (❌ not expected).

If I'm reading the documentation for Update behavior right (more specific Rule 2: Non object update), the product's (array) property values should be replaced, as it is a non object. In fact I think that the second example close to identical to what I'm doing.

I'm expecting the same behavior as when clicking the Remove this attribute in the GUI.

ahocquard commented 7 years ago

Hi @pardahlman ,

Actually, the behaviour for the product values is particular : https://api.akeneo.com/documentation/update.html#patch-product-values

Following the documentation, it's normal that it does not delete the other attribute.

FYI, if it would have been the same behaviour as for the other entities, it would have those drawbacks :

I hope it was clear enough :)

pardahlman commented 7 years ago

Hello @ahocquard - thanks for making this clear to me. I see that it makes sense in the scenarios you described. However, I also see scenarios where it would be desirable to remove product values from the product all together (similar to what the GUI lets you do with). Especially if the attribute is a bool type, where the existence of the value have significance downstream. Is there a way for me to remove values from a product through the API?

The closest I see is this example , that allows me to remove the value's data, but not the attribute value altogether.

ahocquard commented 7 years ago

For now, this is the way to go. We are well aware that's is not the ideal solution and it will be fix in a patch or in a next version (it implies to clean the product values in DB and it's not the ideal solution in a patch...).

On the boolean part, the main problem is not the API, it's the UI that does not handle boolean true/false/null but only true/false.

I think that the problem is on track and will be fix in the next version.

pardahlman commented 7 years ago

I've gotten the answers I was looking for, thanks! It's up to you if you want to close the issue or keep it open for reference for the fixes you suggest.

ahocquard commented 7 years ago

You're welcome, I close the issue.