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 #20842

Merged
merged 6 commits into from
Apr 29, 2019

Conversation

ygyryn
Copy link
Member

@ygyryn ygyryn commented Jan 31, 2019

Fixed issue with not correct updating products category_ids through /rest/ for custom_attribute { 'category_ids } data.

Description (*)

Added call of assignProductToCategories method in \Magento\Catalog\Model\ProductRepository::save
in case when a product currently don't have extension attributes.
This is needed to fix a problem with not correct updating category_ids when try to update the product with /rest/all/V1/products/ through custom_attribute { 'category_ids': '['10127', '10048'] },

Fixed Issues

#20481: REST products update category_ids cannot be removed

Manual testing scenarios (*)

  1. Open in swagger catalogProductRepositoryV1 and call PUT: /V1/products/{sku}

  2. Use test product with such test case:
    "custom_attributes": [
    {
    "attribute_code": "category_ids",
    "value": [
    "1", "2", "3", "4"
    ]
    }
    ]
    testcase

Result will be such: all category_ids with provided id's "1", "2", "3", "4" will be assigned to product.

  1. Then try to remove some categories:
    "custom_attributes": [
    {
    "attribute_code": "category_ids",
    "value": [
    "1", "3"
    ]
    }
    ]
    Result will be such: category_ids with provided id's "1", "3" will be assigned to product.
    Other category_ids, that where before, will be unassigned from product, as expected.

So now category_ids are updated correct!

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Jan 31, 2019

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team
Copy link
Contributor

Hi @ygyryn. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

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

@magento-engcom-team magento-engcom-team added Component: Catalog Release Line: 2.3 Partner: ISM eCompany Pull Request is created by partner ISM eCompany partners-contribution Pull Request is created by Magento Partner labels Jan 31, 2019
@dmytro-ch dmytro-ch self-requested a review February 2, 2019 16:26
@dmytro-ch dmytro-ch self-assigned this Feb 2, 2019
@dmytro-ch
Copy link
Contributor

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @dmytro-ch. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @dmytro-ch, here is your new Magento instance.
Admin access: https://pr-20842.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@dmytro-ch
Copy link
Contributor

dmytro-ch commented Feb 6, 2019

Hi @ygyryn, thank you for your contribution!

There are couple of test failures with the current solution in Magento\Catalog\Test\Unit\Model\ProductRepositoryTest.
Could you please check and update Unit tests for product repository according to the latest changes in code?

Thank you.

@magento-engcom-team
Copy link
Contributor

Hi @dmytro-ch, thank you for the review.
ENGCOM-4173 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

@ygyryn thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@m2-assistant
Copy link

m2-assistant bot commented Apr 29, 2019

Hi @ygyryn, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@siliconalchemy
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Award: complex Component: Catalog Partner: ISM eCompany Pull Request is created by partner ISM eCompany partners-contribution Pull Request is created by Magento Partner Progress: accept Release Line: 2.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants