-
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
Changing attribute from swatch to dropdown deletes swatch options for all attributes #20396
Comments
Hi @maderlock. 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 @maderlock do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
@magento-engcom-team give me 2.3-develop instance |
Hi @maderlock. Thank you for your request. I'm working on Magento 2.3-develop instance for you |
Hi @GovindaSharma. Thank you for working on this issue.
|
Hi @maderlock, here is your Magento instance. |
Hi @engcom-backlog-nazar. Thank you for working on this issue.
|
Got kicked out of the instance as another user logged in. I assume @GovindaSharma or @engcom-backlog-nazar is looking at this, so we will leave this for now. |
Hi @Surabhi-Cedcoss. Thank you for working on this issue.
|
@maderlock did you check this -> #12695 |
In my description I mention that this problem was caused by the fix for #12695. This bug is the opposite problem. |
@maderlock ok, i'm not read all description :) , just remembered that somewhere we have same issue |
@maderlock i'm not able to reproduce following steps you described, can you check test instance ? |
Confirmed reproduced using steps above on 2.3-develop instance. |
@maderlock on vanila instance ? |
@maderlock But you don't set value for you text swatch to default store, how they can be shown? this is non issue. |
Please explain. This displayed entirely correctly until changing back to Dropdown. After I applied my fix the values remained. As far as I understand it there is no need to set a specific value per store. I am happy to retest with values for the default store, but I am unimpressed at the abrupt closure of this issue. |
I can confirm that even with values set on the text swatch for the default store, following the above steps the swatch option table is still cleared as described. Please note that you cannot see this change from the admin side. |
@maderlock Because if you change attribute to text swatch you need enter value for this label, this is non issue. |
@maderlock after that, text swatch is showing on frontend. |
I have re-tested again with entering the values you describe. Problem still occurs as described. Please follow all steps as described. It may be necessary to clear cache before viewing frontend the after changing attribute A. |
If you save the text attribute again, yes this will display correctly on the frontend as it will re-populate the eav_attribute_option_swatch table. But it should not be being emptied to start with. |
If you are uncertain that this is an issue, I recommend looking at the contents of the eav_attribute_option_swatch table before and after changing attribute A back to dropdown. You will notice that before there are values for two attributes, and afterwards there are values for none (rather than just for one). |
@maderlock ok |
@maderlock sorry i'm little bit confused for later issue about it, now clearly and i'm able to reproduce this. |
@engcom-backlog-nazar Thank you for verifying the issue. Based on the provided information internal tickets |
Thanks for the detailed research @maderlock, I can reproduce and your suggested change fixes it. I've created a PR over here: #20421 |
Hi @maderlock. Thank you for your report. The fix will be available with the upcoming 2.3.1 release. |
We've come across this issue too on 2.2.7 website, can this fixed also be rolled out in 2.2.8 update? |
Hi @maderlock. Thank you for your report. The fix will be available with the upcoming 2.2.9 release. |
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
If you look at table eav_attribute_option_swatch, once the attributes are made this is populated with options for both attributes. After changing the type of attribute A back to dropdown this table clears completely, removing both the swatch option data for attribute A and (incorrectly) attribute B.
The cause of this looks to be the fix put in place for #12695. Code was added to clear down the entries for this table when changing an attribute from swatch to dropdown, but there was an error in construction of the SQL meaning that the WHERE statement got partially cleared, so that too much data gets cleared.
Here is the code that causes the issue, from app/code/Magento/Swatches/Model/ResourceModel/Swatch.php:
The line that causes the problem is
$where = ['option_id' => $optionId];
. When the data is passed to the Zend framework, it expects the format to be['option_id = ?' => optionId]
. This is because Zend will look for the '?' to strip out (whilst preparing the SQL, it uses this for data binding). So if the '= ?' is missing Zend will strip out the intended field value. This turns the SQL into aDELETE FROM eav_attribute_option_swatch WHERE (option_id);
hence why the table is cleared down.We have added a plugin on our installation to replace this missing
= ?
and this seems to resolve it in 2.2.7.Checking 2.3, the same error is still in the Swatch.php, so we suspect this is still an issue on that version.
The text was updated successfully, but these errors were encountered: