# etechflow/module-mega-menu

> Theme-agnostic mega menu for Magento 2. Renders on Hyvä, Luma, Adobe Commerce default and custom themes via automatic runtime detection. Provides a JSON endpoint for lazy-loaded subcategory + featured-product data.

`composer require etechflow/module-mega-menu`

Canonical URL: https://packagento.com/etechflow/module-mega-menu

## At a glance

- **Vendor**: etechflow (https://packagento.com/etechflow.md)
- **Latest version**: 1.0.0 — released 2026-06-10
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/etechflow/module-mega-menu and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require etechflow/module-mega-menu:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Theme-agnostic mega menu for Magento 2. Renders on Hyvä, Luma, Adobe Commerce default and custom themes via automatic runtime detection. Provides a JSON endpoint for lazy-loaded subcategory + featured-product data.

## README

A theme-agnostic mega menu for Magento 2.

### At a glance

- **Themes supported:** Hyvä, Luma, Adobe Commerce default, and any custom theme inheriting from either.
- **No jQuery dependency** in the Luma variant — uses vanilla JS only, so it stays light and works in lean themes.
- **No Knockout / RequireJS** in the Hyvä variant — uses Alpine.js (already shipped with every Hyvä theme).
- **Lazy-loaded data:** dropdown subcategories + featured products are fetched on first hover from a 1-hour-cached JSON endpoint (`/megamenu/products/index?cat=<id>`).
- **Auto theme detection** at runtime — picks the right template per request.

### Quick install

```bash
## from your Magento root
cp -r /path/to/Etechflow_MegaMenu app/code/Etechflow/MegaMenu
bin/magento module:enable Etechflow_MegaMenu
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:flush
```

See the top-level **INSTALL.md** in the distribution ZIP for full instructions (3 install methods, production-mode notes, troubleshooting).

### Where to configure

Stores → Configuration → eTechFlow → Mega Menu:

- Master enable/disable
- Root Category ID (which category's children become the top-level menu items)
- **Attach All Active Categories** — Yes = every active category & sub-category auto-shows on enable, even ones set to "Include in Menu = No". No (default) = respect each category's flag. (Categories attach automatically either way — this just controls hidden ones.)
- **Custom Menu Links** — add your own top-level items (Label + URL/path + Sort). They merge in after the category items. Lets admins add custom links without touching categories.
- Max depth, featured products per category, mobile drill-down toggle, cache TTL
- **Featured Products Source** — choose what fills each dropdown's product column:
  Category Position (default) / Newest / Best Sellers / On Sale / Price Low→High / Price High→Low
- **Dropdown Promo CMS Block** — optional CMS block identifier rendered as a banner/column
  inside every dropdown (Content → Blocks). Leave blank for none.

### Files

```
Etechflow_MegaMenu/
├── composer.json
├── registration.php
├── etc/                # module.xml, config.xml, acl.xml, routes.xml, system.xml, di.xml
├── Controller/         # JSON endpoint (megamenu/products/index)
├── Block/              # MegaMenu renderer (picks template by theme)
├── ViewModel/          # MenuData — top-level categories + theme detection
├── Model/Config.php    # Typed config reader
├── view/frontend/      # Layout, both phtml variants, CSS, vanilla JS
└── i18n/en_US.csv
```

### Override points

- **Template:** drop your own `mega-menu.phtml` (or `mega-menu-luma.phtml`) under
  `app/design/frontend/<Vendor>/<theme>/Etechflow_MegaMenu/templates/`.
- **CSS:** override `mega-menu.css` the same way.
- **Block:** subclass `Etechflow\MegaMenu\Block\MegaMenu` and rebind via your theme's `di.xml`.
- **Data:** subclass `ViewModel\MenuData` for custom queries or pre-baked menus.

### Public route

`GET /megamenu/products/index?cat=<id>` → JSON:

```json
{
  "subcategories": [{"id":3,"name":"Range Rover","url":"https://…","count":42}, …],
  "products":      [{"name":"…","price":29.99,"price_formatted":"£29.99","url":"…","img":"…"}, …]
}
```

### License

MIT — see `LICENSE.md` in the distribution.

## Recent Versions

| Version | Released |
|---|---|
| 1.0.0 | 2026-06-10 |

## Dependencies

### Require

| Package | Constraint |
|---|---|
| magento/framework | >=103.0 |
| magento/module-catalog | >=104.0 |
| magento/module-config | >=101.0 |
| magento/module-store | >=101.0 |
| magento/module-theme | >=101.0 |
| php | >=8.1 |

## Quality

Latest release (1.0.0) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | Pass |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 110 | 16 errors, 94 warnings (ruleset: Magento2) — 47 auto-fixable with phpcbf |
| PHPMD | Warning | 8 | 8 rule violations (NPathComplexity:3, MissingImport:2, CyclomaticComplexity:1, ExcessiveMethodLength:1, ErrorControlOperator:1) |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 6 | valid; 6 advisory notes (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 17 | 17 | – | – |
| 2.4.8 | – | 17 | 17 | – |
| 2.4.9 | – | – | 16 | 16 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["etechflow/module-mega-menu"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

etechflow is a Magento 2 vendor on Packagento. See https://packagento.com/etechflow.md for their full catalogue.

