# Auto Switch Home Documentation

Installation steps and a complete reference for every setting, with concrete examples — the same level of detail our support uses to help customers.

## Installation

### Requirements

Magento 2.4.x — tested on 2.4.9, compatible with previous 2.4.* releases. PHP 8.1–8.5. Magento cron must be running (the switch runs daily). Compatible with both the default Luma theme and the Hyvä theme. Depends on the free `codingrow/module-core` module, installed automatically.

### Setup steps

1. Add the credentials you'll receive by email to `auth.json` in your Magento project root:
   ```json
   { "http-basic": { "repo.codingrow.com": { "username": "...", "password": "..." } } }
   ```
2. `composer config repositories.codingrow composer https://repo.codingrow.com`
3. `composer require codingrow/module-auto-switch-home`
4. `bin/magento module:enable Codingrow_AutoSwitchHome`
5. `bin/magento setup:upgrade && bin/magento setup:di:compile && bin/magento cache:flush`

### Configuration

**Stores → Configuration → Codingrow Extensions → Auto Switch Home.**

| Setting | What it does | Default | Notes |
|---|---|---|---|
| **License Key** | The license key issued for this domain. | — | Paste it after purchase, then flush the cache. Accepts a single-module key or a Codingrow subscription key. |
| **Enable automatic home switching** | Turns the daily switching on. | No | On first enable, the store's current home page is remembered; on disable, it is restored. |
| **Switch calendar** | The list of rules. Each row = a recurring **Day** + **Month** and the **CMS page** to show from that date on. | — | Add as many rows as you like. The menu lists your Magento CMS pages. |

Example (seasonal): `21 March → Spring`, `21 June → Summer`, `21 September → Autumn`, `5 December → Christmas`, `26 December → Winter`.

### Uninstallation

Set **Enable automatic home switching** to **No** and save — your original home page is restored automatically. To remove the module entirely: `bin/magento module:disable Codingrow_AutoSwitchHome` then `composer remove codingrow/module-auto-switch-home`.

## User guide

### The switch calendar

Each rule is a recurring **day + month** (no year) mapped to one of your CMS pages. You define the calendar once and it repeats every year. Add a row per transition — there is no limit.

### Which page is active today

The active rule is the one whose day/month is the **most recent that has already occurred**. Example with `5 December → Christmas` and `26 December → Winter`: from 5 to 25 December the home is Christmas, from 26 December it is Winter. The end of the year wraps correctly — in early January the last December rule stays active until the first rule of the new year is reached.

### Daily task and instant apply

A daily cron job (`codingrow_autoswitchhome_apply`, default 00:10, in its own cron group) sets the home page to the active rule. The change is also applied **immediately when you save** the configuration, so you don't have to wait for the cron. Requires Magento cron to be running.

### Non-destructive restore

The module never loses your original home page: it is stored the first time you enable the module and restored automatically when you disable it.

### Cache and reindex

The module refreshes the cache (config + full page) **only on the days the home page actually changes** — a handful of times per year. No reindex is ever required: switching which CMS page is the home is a configuration change, not a catalog index change.

### Hyvä and Luma

The module is theme-agnostic. It only changes which CMS page is the home page, so it works identically on the Hyvä theme and the default Luma theme, with no template changes.

### License

The license is issued for one domain and can be a **single-module** key (Auto Switch Home) or a **Codingrow subscription** key (all modules). Without a valid license the module does nothing. Updates are included within the same major version.
