Skip to content

Color attribute taking swatch instead of Drop down option for configurable options, #9307

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

Closed
vishveskrish opened this issue Apr 19, 2017 · 31 comments
Assignees
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@vishveskrish
Copy link

Preconditions

  1. Magento: 2.1.6

Steps to reproduce

  1. Login to admin-panel and go to the Product >> Attributes.
  2. Created color attribute with Catalog Input Type for Store Owner to "Drop down"
  3. Go to the front-end and open any configurable product with COLOR options.

Expected result

  1. It should display Dropdown select box.

Actual result

  1. It is showing swatch.

Kindly see screenshots.
screenshot-10 16 16 212 2017-04-19 14-37-19
screenshot-10 16 16 212 2017-04-19 14-30-41

@elisabethesbjornsson-vaimo

I am also experiencing this issue, after upgrade from 2.1.4 to 2.1.6.

@lingwooc
Copy link

lingwooc commented May 3, 2017

+1 I had it working originally as a dropdown. Then changed it to a swatch, now I can't go back to a dropdown. The setting saves but the front end ignores it. I assume is is because the extra attributes are created for the options when it is turned into a swatch, then not removed. No amount of cache clearing fixes it.

@gclift
Copy link

gclift commented May 26, 2017

+1 Also had this issue after switching to swatch then back to dropdown. When the product detail page is showing, we're seeing markup with 'swatch-input'. Note, we upgraded from Magento 1.9 to Magento 2.1.6 and imported the data using the magento import tool. It was appearing fine as a drop down until we changed the "Catalog Input Type for Store Owner" from dropdown to Text Swatch.

Markup that appeared after switching to text swatch, and remained after switching back to dropdown:
input class="swatch-input super-attribute-select" name="super_attribute[133]" type="text" value="" data-selector="super_attribute[133]" data-validate="{required:true}" aria-required="true" aria-invalid="true" style="visibility: hidden; position:absolute; left:-1000px"

@vishveskrish
Copy link
Author

Any one get resolution ?

@gclift
Copy link

gclift commented May 30, 2017

I traced the code back to the isProductHasSwatchAttribute in the Magento\Swatches\Block\Product\Renderer\Configurable class. It's using the SwatchAttributesProvider class to check for swatch data.

It looks like there is some leftover data in the eav_attribute_option_swatch table after switching back to the dropdown. Once I cleaned out the swatch values that were created when we switched to the text swatch, it worked as expected again.

To see if there is data, and get the swatch_ids, use this sql query:
Note: Change YOUR_ATTRIBUTE_ID to the id of your attribute.
SQL

SELECT o.option_id, o.attribute_id, s.swatch_id
FROM eav_attribute_option AS o
JOIN eav_attribute_option_swatch AS s ON(o.option_id = s.option_id)
WHERE o.attribute_id = YOUR_ATTRIBUTE_ID
ORDER BY s.swatch_id ASC;

@ghost
Copy link

ghost commented Jun 12, 2017

Having this issue also on 2.1.7.

@imsergiobernal
Copy link

Me too, same issue in 2.1.7

@mayankzalavadia
Copy link
Contributor

We are also facing the same issues on Magento 2.1.7. If anyone finds a solution for this issue then please share it with all.

@lingwooc
Copy link

@gclift gave a manual solution above. It will need some db editing.

@oleg-onufer
Copy link
Contributor

Hi @vishveskrish.
Thanks for reporting this issue.
Internal ticket MAGETWO-70321 was created.

@veloraven veloraven added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report labels Jun 29, 2017
@sdotsuk
Copy link

sdotsuk commented Jul 19, 2017

Using your preferred database editor, navigate and find the table eav_attribute_option_swatch

Magento will store a row for each of the swatches you have configured in the Magento Admin.
Pay attention to the option_id select each row you want to remove as a swatch not forgetting to remove any other associated rows which contain the same option_id.

Once deleted. Head over to your Magento admin panel, clear the magento cache and static file cache.

I was able to solve my issue in 5 minutes. I hope this helps somebody else

@gboz17
Copy link

gboz17 commented Jul 19, 2017

Thanks @sanjeshsodha !!

I can confirm this works.

@mattdillon100
Copy link

Thanks @sanjeshsodha your solution worked for us.
@magento-team is there any update as to why this happens and when it will be fixed?

@korostii
Copy link
Contributor

@wildcard27, well, I could tell you why it happens is this scenario: #9923 (comment)

But an official fix might take a couple more months to get implemented and released, speaking optimistically.

@mattdillon100
Copy link

@korostii So not as simple as programmatically deleting all of the entries in the eav_attribute_option_swatch table relating to the attribute being saved if the frontend type is changed? If so, this could be implemented in a plugin as a 'quick' fix for now.

@korostii
Copy link
Contributor

@wildcard27, That might break the actual swatch attributes that should not look like dropdown, so be careful down that road. But yeah, that might work.

Personally, I don't think there's a "quick" solutions here. I mean, there were whole classes written around implementing some parts of the swatches' rendering, it seems to be an interdependent a fragile thing.

I wish the guys at Magento would test this better though. I mean, they have the resources for it and ytet they release this piece of buggy functionality in a patch version while ignoring hundreds of safe one-liners that await months for a backport. Frankly, that whole routine makes me somewhat angry every time I stumble upon its results, again and again.

@saeohioalpha
Copy link

I was able to fix this by:

Step 1: Finding my attribute id by:
SELECT * FROM magento_store.eav_attribute where attribute_code = 'you_attribute_code'

Step 2: Running the SQL Query referenced above to confirm the swatch entries:
SELECT o.option_id, o.attribute_id, s.swatch_id FROM eav_attribute_option AS o JOIN eav_attribute_option_swatch AS s ON(o.option_id = s.option_id) WHERE o.attribute_id = 'you_attribute_id' ORDER BY o.option_id ASC;

Step 3: Delete the swatch entries.
For me I didn't have any attributes that should be swatches, so I truncated the eav_attribute_option_swatch table and then cleared all the caches, and my swatches turned into dropdowns.

If you have more complicated setup with legit swatches, you may want to only delete the results from the query in step 2.

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team
Copy link
Contributor

@vishveskrish, thank you for your report.
We've created internal ticket(s) MAGETWO-70321 to track progress on the issue.

@magento-engcom-team magento-engcom-team added Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 11, 2017
@vishveskrish
Copy link
Author

Hello @magento-engcom-team,

Do we get the resolution?

@RakeshJesadiya
Copy link
Contributor

I am also experiencing this issue, after upgrade from 2.1.3 to 2.2.0
Any update for this issue?

@s00071609
Copy link

website

What are these blank fields (super attribute) - unwanted fields showing not sure what is wrong with M2.2.1

@jmtakahashi
Copy link

@vishveskrish
Copy link
Author

@RakeshJesadiya , Yes I got the resolution

@eugene-shab
Copy link
Contributor

#mageconf

@eugene-shab eugene-shab self-assigned this Dec 15, 2017
@eugene-shab
Copy link
Contributor

Closed because duplicate #12695

@gouravsyscraft
Copy link

Thank you very much @saeohioalpha . You save my day. your solution is working fine but i am confused like each time when i will create configurable product then i need to do this step?

Still magento not resolved this issue?

@sidolov sidolov added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jun 24, 2018
@prashantvalanda
Copy link

Temporary work around:

Change your attribute to dropdown from swatch from admin

go to database >> table eav_attribute_option_swatch

delete all related swatch attribute row from this table

deploy static content and flush cache.

@ishakhsuvarov
Copy link
Contributor

Hi @vishveskrish. Thank you for your report.
The issue has been fixed in #17750 by @nmalevanec in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@ishakhsuvarov ishakhsuvarov added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Sep 11, 2018
@diamondavocado
Copy link

@ishakhsuvarov I'm still having this issue on 2.3.0. I'm unable to change my attribute type from Text Swatch to Dropdown, even if I truncate the swatch options table.

@aliomattux
Copy link

I also had a similar issue but believe the attribute was changed from a dropdown to a text swatch. On the front end, it looks like below. I only found out about this issue by looking through bug reports. After I saw this report, I changed it back to a dropdown and it works again.
Magento 2.3.3
2020-03-10_23-55-37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests