Skip to content
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 (from #20481) #25646

Closed
siliconalchemy opened this issue Nov 18, 2019 · 7 comments
Closed
Assignees
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@siliconalchemy
Copy link

** Note: This is a continuation of #20481, which in turn is a continuation of #14038. Both of these issues were closed without a correct fix in place **

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.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Nov 18, 2019
@m2-assistant
Copy link

m2-assistant bot commented Nov 18, 2019

Hi @siliconalchemy. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@siliconalchemy do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@siliconalchemy
Copy link
Author

My workaround is to edit vendor/magento/module-catalog/Model/Category/Link/SaveHandler.php and change:
$processLinks = $this->mergeCategoryLinks($dtoCategoryLinks, $modelCategoryLinks);
to
$processLinks = $modelCategoryLinks;

Deleting categories then works perfectly for me, but I don't know what other impacts that could have.

@engcom-Charlie engcom-Charlie self-assigned this Nov 20, 2019
@m2-assistant
Copy link

m2-assistant bot commented Nov 20, 2019

Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented Nov 20, 2019

Hello @siliconalchemy

Thank you for contribution and collaboration!

We are not able to reproduce this issue on the latest 2.3-develop branch by provided steps.

Testing scenario:

  1. Get the product which assigned to a lot of categories:
    image

  2. Update the product(make a PUT request without two categories):
    image

  3. Get the product again

Result:
Categories have been deleted:
image
image

We are closing this issue due to branch 2.2-develop was closed and

Magento no longer accepts pull requests and issues to the v2.2 release lines to focus all development efforts on v2.3.

See Accepted pull requests and ported code for more details

If you still faced this issue on 2.3 please create a new Issue with all required details according to Issue reporting guidelines

Thanks for your report!

@siliconalchemy
Copy link
Author

Huh, yes I still have this issue in 2.3.3.

@engcom-Charlie
Copy link
Contributor

@siliconalchemy i can't confirm issue of it only for 2.3.3( because 2.3.3 codebase has been merged in 2.3-develop) you can see info about it here:
image

@gdvisser
Copy link

gdvisser commented Aug 2, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

4 participants