-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REST products update category_ids cannot be removed #20481
Comments
Hi @siliconalchemy. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
where @siliconalchemy do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
Hi @engcom-backlog-nazar. Thank you for working on this issue.
|
@engcom-backlog-nazar Thank you for verifying the issue. Based on the provided information internal tickets |
Hi @vpodorozh. Thank you for working on this issue.
|
Hi @ygyryn. Thank you for working on this issue.
|
@magento-engcom-team give me 2.3-develop instance |
Hi @dmytro-ch. Thank you for your request. I'm working on Magento 2.3-develop instance for you |
Hi @dmytro-ch, here is your Magento instance. |
Code review, updated unit tests
Hi @siliconalchemy. Thank you for your report.
The fix will be available with the upcoming 2.3.2 release. |
As of Magento 2.3.3, this problem is NOT fixed. Assigning a reduced list of category_ids does not correctly remove remaining category_ids that should no longer be there. |
In which version is this fixed? |
@magento-engcom-team Still a problem in 2.3.4. @siliconalchemy It looks like the issue resides in the Something odd to take note of is that this is also used when saving products in the admin panel, but it appears that the order of parameters are reversed where I'll need to do a bit more digging, but it really looks like this function is just nonsense. Maybe it was an attempt to preserve the category order? If so, it could have been done in a sensible way. |
@simonworkhouse - Magento don't care. See #25646. I just hack my fix into place for every point release, a long with a bunch of other bugs Magento don't care about fixing. Edit: actually I made this into a module (unzip into app/code/SiliconAlchemy to use) in case it's useful for anyone: |
@siliconalchemy Ah, I didn't see that one, but thank you. It looks like I found the same source of the issue as you did. It astonishes me that Magento was sold for ~$1.7b, I honestly didn't know piles of manure could be so expensive. |
some ruff climate here... Anyways, a shout out to leonardo_pinhei: the trick seems to be setting (the default custom attribute) category_ids to null/empty in addition to the
I actually like the fact that you can control whether or not to keep existing categories using this attribute now that I know about it... ;) |
@cfarnleitner - You think that an obscure bug (or at least obscure undocumented handling) in an API is a good way to fix a major bug in an API? |
As long as this is not fixed in Magento you can take this approach: https://stackoverflow.com/questions/68622618/magento-2-rest-api-cant-remove-category-ids/68623022#answer-68623022 |
I've encountered this on Magento 2.4.2 today. Shocked to find I'll be needing to unset this everytime if need be! |
** Note: This is a copy of issue #14038, which was assigned to someone who has no idea how to reproduce or fix it and seems to be permanently stuck **
Preconditions and Steps to Reproduce
For example, if a product currently has custom_attribute { 'category_ids': '['10127', '10048', '10123', '10126'] }, and I want to remove two of the categories from the product by setting this to { 'category_ids': '['10127', '10048'] }.
I then update the product with /rest/all/V1/products/ with the updated data. I get a success returned, and any other product data is successfully updated, and categories can be added to, but trying to remove categories such as above fail silently. The category_ids remain with the original 4 categories, as in the example above.
Magento 2.2.3
Php 7.1, Mysql 5.7 (Percona Xtradb Cluster)
Expected Result
I expect to be able to remove categories. This worked until 2.2 upgrade.
Actual result
See description. Categories are not updated, but the update command reports success.
The text was updated successfully, but these errors were encountered: