Magento2: Dropdown on configurable products page is missing when using caches [Magneto 2.1.0]

Created on 24 Jun 2016  路  14Comments  路  Source: magento/magento2

Steps to reproduce

  1. I am using Magento 2.1.0 (after update form Magento 2.0.7 using Setup Wizard + MDVA-532 patch).
  2. Create new configurable product or use one created before the update. It should use 2 configurable attributes: visual swatch and dropdown.
  3. Enable all caches.
  4. Try to add this product to the cart.

    Expected result

  5. On product page, there should be visual swatch and dropdown.

  6. The product should be added to cart successfully.
    exp

    Actual result

  7. Unfortunately, there isn't any dropdown. Just visual swatch.

  8. The product can't be added to cart and this message is displayed under "add to cart" button: "This field is required".
  9. Browser console is clear of any errors.
    is

    Follow these steps, to see dropdown on just one product
  10. In one tab open admin panel and in second open category page on store front.

  11. Enable all caches and "Flush Magento Cache".
  12. Go to any configurable product with dropdown and visual swatches. Dropdown should be missing.
  13. "Flush Magento Cache" one more time.
  14. Refresh product page. Now dropdown is there and it works, but only for this one product.
Catalog Cannot Reproduce Clear Description Format is not valid bug report

All 14 comments

Update

After flushing caches, the dropdown is not working only when accessing the product page through any category page. When accessing it through a widget ("Product list") or search, dropdown is displayed correctly.

I think that this issue is related to "Collections Data" cache.
Dropdown is always displayed, after I disabled "Collections Data" and flushed cache.

Please, have a look at the issue.

@RG-1 i have faced this issue too. i need flush magento cache, it's work for awhile, after that the "Size" dropdown disappear again.

I am also experiencing this same issue. Clearing the cache temporarily resolves the issue. I find that if you clear the cache, visit a category page first, and then a configurable product page you'll be able to reproduce the issue every time.

I tracked the issue down to this method

Magento\ConfigurableProduct\Model\Product\Type\Configurable::getConfigurableAttributes

It caches configurable attributes and their options. What happening for us is that when browsing a category page, only a subset of the configurable attributes are needed (i.e. for layered nav). That cache entry gets saved. Then when you browse to a product page, it picks up that cache entry from the category page. That cache entry doesn't contain ALL the config attributes, so the dropdowns are empty.

There really needs to be 2 cache entries. One specifically for the category page, and one for the production page. Right now it's just cached by product and store ID.

Have the same issue, is there a workaround?

One workaround is update catalog_eav_attribute set used_in_product_listing = 1 where used_in_product_listing = 0; (or just update the attributes that are configurable on your products) and deal with the consequences on the frontend.

Another way is to seperate cache identifiers for catalog and product view. Inject a request object in the constructor (don't judge me for placing controller code in the model), change the Magento\ConfigurableProduct\Model\Product\Type\Configurable.php::getConfigurableAttributes() method and insert an ugly controller name check after the $cacheId initialization:

if($this->request->getControllerName() == "product") {
    $cacheId = "product-" . $cacheId;
} else if ($this->request->getControllerName() == "category") {
    $cacheId = "category-" . $cacheId;
}

Also you have to change the save method, to remove caches by their new key.

@RG-1, thanks for reporting this issue
Unfortunately I could not reproduce this issue. May you please advise if this problem is still relevant for latest release Magento 2?

After flushing caches, the dropdown is not working only when accessing the product page through any category page. When accessing it through a widget ("Product list") or search, dropdown is displayed correctly.

Hi @IlnitskiyArtem
Confirmed: Experienced the same symptoms on 2.1.7.
Steps to reproduce: save attribute with frontend input "Text Swatch", switch back to dropdown, select won't appear on the product page (only the label shows up).
Attribute created before upgrade from 2.1.5 to 2.1.7 shows up okay.

@korostii, Excuse me, but I didn't understand the comment.
You change frontend input type from "Text Swatch" to "Dropdown".
And attribute Is displayed as "Text Swatch" on the product page?

Hi @IlnitskiyArtem, maybe you should've read it more carefully.
First I switched from "Dropdown" to "Text swatch", and then back to "Dropdown".

Result: "select won't appear", meaning the attribute's dropdown is not displayed at all (not as swatch, not as dropdown, just the label), but only on product page.

Do you speak English okay or are you using a translator? I can duplicate the description in Russian, if that'd be easier for you to understand.

@korostii please create separate GitHub issue for the issue you describe as it differs from the one described by @RG-1 in this issue report. You change attribute type while in his case attribute is just not displayed according to the description.

Hi @IlnitskiyArtem, the symptoms are the same.
I'd rather guess the reporter missed some steps because he didn't think they're relevant.

If you'd like a different issue, here, have it: #9923 has exactly the same symptoms I do.

@RG-1, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.

Was this page helpful?
0 / 5 - 0 ratings