1

First things first, this problem is already described and acknowleged as a bug on Github.

If FPC (varnish) is enabled, the active HTML class will be missing from the category menu on the frontend. None of the usual things helps including rm -rf pub/static/*, redeploying static, reindexing or flushing caches.

Though the currently active category receives the proper HTML class if you disable FPC.

Since this problem is known but the Magento team seemingly not interested in fixing it. I'd like to know if anyone has found a way around this behavior - neither disabling the cache nor having no visual clue of the current category is desirable.

  • I have a website running with varnish where i do not encounter that problem. What are your varnish settings and file and also do you have a host? Because i demanded my host to make a custom varnish file with their settings. Also what are your http / https settings in your backend? (the use web secure url settings and use web unsecure). So many things to check – CompactCode Jul 27 '17 at 14:47
  • Well - Varnish settings are the Magento2 generated settings. I assume by host you mean some hosting provider - no I don't, the shop is running on a VPS server. It is only available over HTTPS, so there's no HTTP at all - the URLs don't need to be modified. Though I wonder why they should be an issue at all - Varnish is working fine, otherwise. – Moritz Friedrich Jul 27 '17 at 14:49
  • Default .vcl settings that magento outputs + https does generate issues. Error top menu's are results of that. You need to edit the .vcl settings. How you need to do that i can not tell you. I had issues also and my hosting provider fixed it by editing the varnish fille and varnish configuration. So you might want to dig into that if you want to resolve it. Obviously the part that is responsible for giving it an active class is not getting trough. This part i do know where to find and you can find it in vendor/magento/framework/Data/Tree/Node.php -> return $this->_getData('is_active') – CompactCode Jul 27 '17 at 16:03
  • Well - the complete setup is a bit larger.. essentially, we have (https) nginx:443 -> (http) varnish:8080 -> (http) nginx:3001 -> (http) php-fpm.socket -> (http) magento -> (https) nginx -> client output. So internally, the whole stack uses HTTP which should work fine, AFAIK. But I'll look into it, thank you! – Moritz Friedrich Jul 27 '17 at 16:07
  • where that is been used is in app/code/Designit/MegaMenu/Block/Html/Topmenu.php under _getMenuItemClasses by : if ($item->getIsActive()) { $classes[] = 'active'; } elseif ($item->getHasActive()) { $classes[] = 'has-active'; } – CompactCode Jul 27 '17 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.