Skip to content

Magento2 attribute option does not validate for existing records before insert 16852 #21424

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

Conversation

novikor
Copy link
Contributor

@novikor novikor commented Feb 24, 2019

Description (*)

See #16852 for the problem details.

New logic implemented:

  1. Check if option exists.
  2. If option does not exist - create new option.
  3. If option exists - check the sort order of the option.
  4. If option exists in DB and option in the request has other sort order than option in DB - update the sort order.
  5. If option in DB exists and has the same sort order in DB - do nothing.

Fixed Issues (if relevant)

  1. Magento2 Attribute option does not validate for existing records before insert #16852: Magento2 attribute option does not validate for existing records before insert

Manual testing scenarios (*)

  1. Create a product eav attribute dynamically using class (Magento\Catalog\Model\ResourceModel\Eav\Attribute) and set the entity type Id to the type id of catalog_product (See sample code below) (eg: attribute code = colors)
  2. generate a list of possible options and then add those options into that product EAV attribute by using (Magento\Eav\Setup\EavSetup -> AddOption()) (optionarray = 'Black, Blue, White')
  3. Generate some more options (pick some of those which are already existed) and add then add them into the product attribute by following the same step describe in step 2. ('White, Green, Purple')

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-engcom-team
Copy link
Contributor

Hi @novikor. 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: Eav 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 Feb 24, 2019
@novikor novikor requested a review from swnsma February 24, 2019 21:52
@novikor
Copy link
Contributor Author

novikor commented Feb 24, 2019

@swnsma , please review.

I will cover this logic by integration tests later.

Copy link
Contributor

@swnsma swnsma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @novikor,

Please check my notices.
Please add unit and integration tests.

@novikor
Copy link
Contributor Author

novikor commented Mar 25, 2019

@swnsma , please review: requested changes have been applied and integration tests provided.

Copy link
Contributor

@swnsma swnsma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally good, but some changes is required.

@ghost ghost assigned orlangur Apr 6, 2019
@novikor novikor requested a review from swnsma April 6, 2019 15:41
@novikor novikor force-pushed the Magento2-Attribute-option-does-not-validate-for-existing-records-before-insert-16852 branch from c1603a2 to 448f3e9 Compare April 13, 2019 10:00
@orlangur
Copy link
Contributor

@novikor no objections from my side if @swnsma will finish review.

Please squash changes into a single commit so that we have perfectly clean history 😉

@orlangur orlangur removed their assignment Apr 14, 2019
@orlangur orlangur dismissed their stale review April 14, 2019 22:40

complete solution is not implemented here

@orlangur
Copy link
Contributor

@novikor @swnsma

I have doubts regarding

If option exists in DB and option in the request has other sort order than option in DB - update the sort order.

Such behavior may lead to position update not noticed by merchant. Much cleaner approach is to show a validation error instead so that merchant may decide what to do.

@novikor novikor force-pushed the Magento2-Attribute-option-does-not-validate-for-existing-records-before-insert-16852 branch from 5473e41 to 57a09bd Compare May 4, 2019 21:41
@novikor
Copy link
Contributor Author

novikor commented May 4, 2019

@orlangur - I succeeded to squash only the last commits after the merge with the upstream branch and failed to process the rest.
@swnsma, we need to discuss this PR.

@orlangur
Copy link
Contributor

orlangur commented May 6, 2019

@novikor create a new branch out of 2.3-develop and git merge --squash this old branch into it.

@novikor novikor force-pushed the Magento2-Attribute-option-does-not-validate-for-existing-records-before-insert-16852 branch from f49606a to e910a3b Compare May 16, 2019 08:10
@sivaschenko
Copy link
Member

@akaplya can you please approve the SVC build failure (Magento\Eav\Setup\EavSetup::__construct optional param introduced)

@swnsma
Copy link
Contributor

swnsma commented Jul 17, 2019

Hi @akaplya,
Any updates?

@swnsma
Copy link
Contributor

swnsma commented Aug 19, 2019

@magento run all tests

@swnsma
Copy link
Contributor

swnsma commented Aug 20, 2019

@sivaschenko, it is look like re-run of tests fixed the problem :)
Can we proceed with the PR?

@magento-engcom-team
Copy link
Contributor

Hi @swnsma, thank you for the review.
ENGCOM-5131 has been created to process this Pull Request
✳️ @swnsma, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@swnsma swnsma added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Aug 23, 2019
@kalpmehta kalpmehta self-assigned this Sep 7, 2019
magento-engcom-team pushed a commit that referenced this pull request Sep 10, 2019
@magento-engcom-team magento-engcom-team merged commit a8ec393 into magento:2.3-develop Sep 10, 2019
@m2-assistant
Copy link

m2-assistant bot commented Sep 10, 2019

Hi @novikor, 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.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.4 milestone Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Award: special achievement Award: test coverage Component: Eav 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.

9 participants