Search by

infrangible / m2-context-topmenu

infrangible

Lets the top navigation menu differ by customer context, such as customer group, without wrong menus being served from the cache.

Package info

github.com/infrangible-dev/m2-context-topmenu

Homepage

Type:magento2-module

pkg:composer/infrangible/m2-context-topmenu

Statistics

Installs: 257

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.0 2026-11-28 19:49 UTC

This package is auto-updated.

Last update: 2026-11-28 19:50:50 UTC


README

Caches Magento's top menu per visitor context, so that a menu that differs by customer group, login status or currency is never shown to the wrong visitors.

Behavior

Magento keeps the rendered top menu in its block cache for an hour. The cache key contains only the store, the template and the base URL, so all visitors of a store view share one cached menu. When the menu depends on the visitor (for example categories that are shown only to logged-in customers or to one customer group), the first visitor decides what the others see until the cache entry expires.

The module adds the vary string of Magento's HTTP context to this cache key. It is the same information that the full page cache uses to keep visitors apart: customer group, login status, currency and the values that other modules add to the context. Each context gets its own cached menu; visitors with the default context (guests in the default currency) keep Magento's cache entry.

  • This applies with the built-in full page cache, with Varnish and without a full page cache: the block cache is used whenever the menu is rendered.
  • There are no settings.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.6 or newer
  • PHP 8.1 or newer

Installation

composer require infrangible/m2-context-topmenu
bin/magento module:enable Infrangible_ContextTopmenu
bin/magento setup:upgrade

In production mode, also run bin/magento setup:di:compile.

License

Infrangible Context Topmenu is licensed under the MIT License - see the LICENSE file for details.