-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Attribute option(with numeric value) cannot be added in case option with same option_id already exists #33073
Comments
Hi @aleksandrvaimo. 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:
For more details, please, review the Magento Contributor Assistant documentation. Please, add a comment to assign the issue:
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Hi @aleksandrvaimo! 👋 |
Hi @engcom-Alfa. Thank you for working on this issue.
|
Patch for fixing this issue: Fix: Check if attribute exists with numeric option value Issue was found during product import. Also is reproducible in Admin on product attribute page. Before adding the attribute option \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::getOptionId()
@link #33073
|
✅ Confirmed by @engcom-Alfa Issue Available: @engcom-Alfa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself. |
Tried on Magento 2.4 Develop able to replicate. |
@magento I am working on this |
@magento give me 2.4-develop instance |
Hi @SilinMykola. Thank you for your request. I'm working on Magento instance for you. |
Hi @SilinMykola, here is your Magento Instance: https://866b9bb6d526d68472246fc42b8567fd-2-4-develop.instances.magento-community.engineering |
@engcom-Alfa issue is not reproducible and can be closed. |
No as far as I can see this is not a reproduction of the issue, in your example you need to import the product with a package_size with a label identical to an existing option_id AND a new label value. To reproduce with the data available in those screenshots, your product should have product_size 214. With that you should be able to reproduce the issue. |
@magento give me 2.4-develop instance |
Hi @ganeddact. Thank you for your request. I'm working on Magento instance for you. |
Hi @ganeddact, here is your Magento Instance: https://866b9bb6d526d68472246fc42b8567fd-2-4-develop.instances.magento-community.engineering |
Confirming this is an valid issue I just ran across on 2.4.2-p1 Can also confirm the patch provided in #33073 (comment) fixes the issue for me. Thanks @aleksandrvaimo :) |
@magento i am working on this |
I confirm that the problem is reproducible on magento 2.4.4. |
Indeed broken and patch works. |
Hello there, https://drive.google.com/file/d/1vsOx_qQ-qDnEtgyQkH9Y7AdQoP9D0EPQ/view?usp=sharing |
thanks @aleksandrvaimo for the patch! |
Reproducible on 2.4.3-p2, patch is working on it. |
When using This will result in
This, including the original issue, should be fixed. I'll create a new patch addressing both of them. |
New patch:
|
Please notice that at least in 2.4.6 version there are code updates affecting OptionManagement.php. Patch differences can be circunvented but could be problematic to pull the code directly to the current development branch. 2.4.3-p2
2.4.6-p1:
This is the diff file I'm using for 2.4.6-p1 version:
|
First report on 2021.... 2024 and still not fixed |
Patch supplied by @PachisPachis is still OK for 2.4.7-p2. Too bad this issue is still not being resolved, if I've some spare time I'll open a PR (need to create some tests as well). |
Encountered the same issue here, thank you @PachisPachis for the patch, I can confirm it also works on 2.4.7-p3 and hope it will be merged a.s.a.p. |
@PachisPachis where should this patch be applied? |
Nevermind, I was able to track it down. This patch can be applied to creating the patch file in |
Manually patching is not recommended, since the patch will be removed when reinstalling the package. Steps:
From now on everytime you reinstall this package the patch will automatically be applied. |
@pmzandbergen ok that makes sense. I appreciate the details, I'll look at getting this setup to avoid regression. Thanks! |
Hi @aleksandrvaimo , Thanks for your reporting and collaboration. Steps to reproduce 1 Go to Admin > Stores > Attributes[Product]. Thanks. |
Preconditions (*)
Attribute option(with numeric value) cannot be added in case option with same option_id already exists.
OptionManagement->add() methods call for AbstractSource->getOptionId() to find out if given option already exists for given attribute. As getOptionId param add() sends option label. Problem is that getOptionId() checks for both label and option_id (value). So if label is a numerical string and option with same id (but different label) exists, exception is thrown.
Model/Entity/Attribute/OptionManagement
Model/Entity/Attribute/Source/AbstractSource
Steps to reproduce (*)
1 Go to Admin > Stores > Attributes[Product].

1.1 Create or open any multiselect attribute.
1.2 Add new option and save attribute
1.3 Add one more option with value of first option id and save attribute
2 Second option(import): In CSV import products file add new product with select/multiselect attribute with value of existing option_id in eav_attribute_option_value table(eg. in scv file attribute with value: 10,180. In eav_attribute_option_value must exist option with option_id = 10 or 180). Import product by using command:
bin/magento integration:job:run transport_product_import_std_csv
Expected result (*)
new attribute option will be successfully added

Actual result (*)
Error msg in case of import:
Exception: Admin store attribute option label "180" is already exists.
Error msg in admin while saving new attribute option:
The value of Admin must be unique.(180)
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
The text was updated successfully, but these errors were encountered: