# hyva-themes/magento2-compat-module-fallback

`composer require hyva-themes/magento2-compat-module-fallback`

Canonical URL: https://packagento.com/hyva-themes/magento2-compat-module-fallback

## At a glance

- **Vendor**: hyva-themes (https://packagento.com/hyva-themes.md)
- **Latest version**: 1.1.4 — released 2025-11-04
- **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/hyva-themes/magento2-compat-module-fallback 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 hyva-themes/magento2-compat-module-fallback:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## README

[![Hyvä Themes](https://hyva.io/media/wysiwyg/logo-compact.png)](https://hyva.io/)

### hyva-themes/magento2-compat-module-fallback

### Installation

This module is usually installed automatically by composer as a dependency of Hyvä Themes compatibility modules.
If you nevertheless want to install it manually (for example if you would like to contribute), run 

```
composer config repositories.hyva-themes/magento2-compat-module-fallback git git@gitlab.hyva.io:hyva-themes/magento2-compat-module-fallback.git
composer require hyva-themes/magento2-compat-module-fallback
```

### Purpose

This module allows registering Hyvä compatibility modules for automatic view file overrides.
The purpose of this is to avoid boilerplate layout XML and di.xml plugins, when block content is added in a result
programmatically by a module.

Once a module is registered as a Hyvä compatibility module, templates of the original module can be overridden by
placing the `.phtml` file in the same location in the compatibility module.
For example:

Template location in the original module: `Orig_Module::page/example.phtml`
Template location in the compatibility module: `Hyva_OrigModule::page/example.phtml`

In addition to the automatic tempalte overrides, modules registered with the compat module registry will also be
added to the app/etc/hyva-themes.json file, and can hook into the tailwind styles.css build process.

### Usage

Compatibility modules are registered with the `CompatModuleRegistry` using `frontend/di.xml`.

Since modules can have more than one compatibility module, and compatibility modules can
have more than one original module, the constructor argument map can not be a simple associative array.

The argument array structure looks like this:

```
<type name="Hyva\CompatModuleFallback\Model\CompatModuleRegistry">
    <arguments>
        <argument name="compatModules" xsi:type="array">
            <item name="hyva_origmodule_map" xsi:type="array">
                <item name="original_module" xsi:type="string">Orig_Module</item>
                <item name="compat_module" xsi:type="string">Hyva_OrigModule</item>
            </item>
            <item name="hyva_othermodule_map" xsi:type="array">
                <item name="original_module" xsi:type="string">Other_Module</item>
                <item name="compat_module" xsi:type="string">Hyva_OtherModule</item>
            </item>
        </argument>
    </arguments>
</type>
```

The above example registers the module `Hyva_OrigModule` as a compatibility module for both `Orig_Module` and `Other_Module`.

Note: The keys of the first level of the array do not matter, as long as they are unique.

#### Details

The first example in the Purpose section above glossed over some details. The fallback actually contains two additional
folders for each compatibility module. 

This is useful when:
- The compatibility module handles more than one original module.
- Both original modules have a template file with the same name. 

The following lists of fallback modules hopefully make it clear: 

##### Original fallback

1. `<theme_dir>/<module_name>/templates`
2. `<module_dir>/view/<area>/templates`
3. `<module_dir>/view/base/templates`

##### Fallback with one compatibility module for Orig_Module

1. `<theme_dir>/<module_name>/templates`
2. `<compat_module_dir>/view/<area>/templates/Orig_Module`
3. `<compat_module_dir>/view/<area>/templates`
4. `<module_dir>/view/<area>/templates`
5. `<compat_module_dir>/view/base/templates/Orig_Module`
5. `<compat_module_dir>/view/base/templates`
5. `<module_dir>/view/base/templates`

##### Example:

* Original files:
  - `Orig_Module::cookie_bar.phtml`
  - `Other_Module::cookie_bar.phtml`
* Overrides:
  - `Hyva_OrigModule::Orig_Module/cookie_bar.phtml`
  - `Hyva_OrigModule::Other_Module/cookie_bar.phtml`


### License

Copyright © 2020-present Hyvä Themes.

Each source file included in this distribution is licensed under OSL 3.0.

http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
Please see LICENSE.txt for the full text of the OSL 3.0 license.

### Changelog

Please see [The Changelog](CHANGELOG.md).

## Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### [Unreleased]

[Unreleased]: https://gitlab.hyva.io/hyva-themes/magento2-theme-module/-/compare/1.1.4...main

#### Added
- Nothing yet.

#### Changed
- Nothing.

#### Removed
- No removals.

### [1.1.4] - 2025-11-10

[1.1.4]: https://gitlab.hyva.io/hyva-themes/magento2-compat-module-fallback/-/compare/1.1.3...1.1.4

#### Added

- Nothing added

#### Changed

- Changed license to OSL 3.0.

#### Removed

- Nothing removed

### [1.1.3] - 2023-12-08

[1.1.3]: https://gitlab.hyva.io/hyva-themes/magento2-compat-module-fallback/-/compare/1.1.2...1.1.3

#### Added

- Add Exclusion Mechanism for Module Tailwind Config.

#### Changed

- Nothing added

#### Removed

- Nothing removed

### [1.1.2] - 2022-02-21

[1.1.2]: https://gitlab.hyva.io/hyva-themes/magento2-compat-module-fallback/-/compare/1.1.1...1.1.2

#### Added
- Add compat modules to the app/etc/hyva-themes.json configuration file.

  This requires compat modules to be registered with \Hyva\CompatModuleFallback\Model\CompatModuleRegistry in
  the etc/frontend/di.xml file.

#### Changed
- Nothing.

#### Removed
- No removals.


### [1.1.1] - 2022-02-21

[1.1.1]: https://gitlab.hyva.io/hyva-themes/magento2-compat-module-fallback/-/compare/1.1.0...1.1.1

#### Added
- Added methods getCompatModules and getOrigModules

  This will allow generating a console command to dump a list to all compat modules, which in turn then can be used
  to automatically add them to the purge list for tailwind css.

#### Changed
- Nothing.

#### Removed
- No removals.

## Recent Versions

| Version | Released |
|---|---|
| 1.1.4 | 2025-11-04 |
| 1.1.3 | 2023-12-08 |
| 1.1.2 | 2022-03-10 |
| 1.1.1 | 2022-02-21 |
| 1.1.0 | 2021-04-29 |
| 1.0.0 | 2021-04-29 |

## Dependencies

### Require

| Package | Constraint |
|---|---|
| hyva-themes/magento2-theme-module | * |
| magento/framework | * |

## Quality

Latest release (1.1.4) 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 | Warning | 8 | 8 warnings (ruleset: Magento2), 2 auto-fixable with phpcbf |
| PHPMD | Warning | 2 | 2 rule violations (IfStatementAssignment:1, UnusedFormalParameter:1) |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 2 | valid; 2 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 | 102 | 102 | – | – |
| 2.4.8 | – | 102 | 102 | – |
| 2.4.9 | – | – | 98 | 98 |


### 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 | N/A | 0 | no resolvable dependency tree to audit: Your requirements could not be resolved to an installable set of packages. Problem 1 |
| 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=["hyva-themes/magento2-compat-module-fallback"],
  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

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

