PHPackages                             shopwhizzy/magento2-swatchcache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. shopwhizzy/magento2-swatchcache

ActiveMagento2-module[Caching](/categories/caching)

shopwhizzy/magento2-swatchcache
===============================

Magento 2 module to cache swatch configurations for large configurable products

1.0.11(11mo ago)091proprietaryPHPPHP &gt;=7.4

Since Jul 28Pushed 11mo agoCompare

[ Source](https://github.com/shopwhizzy/magento2-swatchcache)[ Packagist](https://packagist.org/packages/shopwhizzy/magento2-swatchcache)[ RSS](/packages/shopwhizzy-magento2-swatchcache/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

ShopWhizzy SwatchCache for Magento 2
====================================

[](#shopwhizzy-swatchcache-for-magento-2)

**Module Name**: shopwhizzy/magento2-swatchcache
**Version**: 1.0.11
**Description**: Magento 2 module to cache swatch configurations for large configurable products, improving performance by reducing frontend rendering time.
**License**: Proprietary
**Author**: ShopWhizzy

Overview
--------

[](#overview)

The `ShopWhizzy_SwatchCache` module enhances the performance of Magento 2 stores with large configurable products by caching swatch configurations (`json_config` and `json_swatch_config`) in the `var/swatches` directory. It includes a console command, a cron job, an observer, and an admin configuration interface to manage cache generation and clearing. Suitable for Hyvä Themes shops.

Features
--------

[](#features)

- **Cache Generation Command**: Run `bin/magento shopwhizzy:swatchcache:generate` to generate cache files for configurable products, with optional product ID filtering and force regeneration.
- **Cron Job**: Automatically generates cache files for a configurable number of products (default: 2) every 2 minutes, skipping products with existing caches or errors.
- **Observer**: Clears cache files for a product when it is saved, if enabled in configuration.
- **Admin Configuration**:
    - Enable/disable cache clearing on product save.
    - Enable/disable cron job with customizable schedule, products per run, and delay between requests.
    - AJAX-powered "Clear All Swatch Cache" button to delete all cache files in `var/swatches`.
- **Performance Optimization**: Skips products with existing caches and handles errors gracefully during cache generation.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- Magento 2.4.x or higher
- Required Magento modules:
    - `Magento_Catalog` (&gt;=103.0.0)
    - `Magento_ConfigurableProduct` (&gt;=100.3.0)
    - `Magento_Swatches` (&gt;=100.3.0)
    - `Magento_Cron` (&gt;=100.3.0)

Installation
------------

[](#installation)

### Via Composer

[](#via-composer)

1. Add the module to your Magento 2 project: ```
    composer require shopwhizzy/magento2-swatchcache
    ```
2. Enable the module and update Magento: ```
    bin/magento setup:upgrade
    bin/magento cache:clean
    ```
3. Deploy static content (if in production mode): ```
    bin/magento setup:static-content:deploy
    ```

### Manual Installation

[](#manual-installation)

1. Download the module and place it in `app/code/ShopWhizzy/SwatchCache`.
2. Enable the module and update Magento: ```
    bin/magento setup:upgrade
    bin/magento cache:clean
    ```
3. Deploy static content (if in production mode): ```
    bin/magento setup:static-content:deploy
    ```

Configuration
-------------

[](#configuration)

1. Navigate to **Stores &gt; Configuration &gt; ShopWhizzy &gt; Swatches Cache** in the Magento admin panel.
2. Configure the following settings:

    ### General

    [](#general)

    - **Enable Cache Clearing on Product Save**: Enable/disable the observer that clears cache files when a product is saved (default: Enabled).

    ### Cron Settings

    [](#cron-settings)

    - **Enable Cron**: Enable/disable the cron job for cache generation (default: Enabled).
    - **Cron Schedule**: Set the cron expression (default: `*/2 * * * *` for every 2 minutes).
    - **Products per Cron Run**: Number of valid products to process per cron run (default: 2).
    - **Delay Between Requests (ms)**: Delay between processing each product in milliseconds (default: 1000ms).

    ### Cache Management

    [](#cache-management)

    - **Clear All Swatch Cache**: Click the button to delete all files in `var/swatches` via AJAX (only visible when cron is enabled).
3. Save the configuration and clear the cache:

    ```
    bin/magento cache:clean config
    ```

Usage
-----

[](#usage)

### Generate Cache Manually

[](#generate-cache-manually)

Run the console command to generate cache files for all configurable products or specific product IDs:

```
bin/magento shopwhizzy:swatchcache:generate [--force] [product_ids]
```

- `--force`: Regenerate cache files even if they exist.
- `product_ids`: Space-separated list of product IDs (e.g., `bin/magento shopwhizzy:swatchcache:generate 1 2 3`).

### Cron Job

[](#cron-job)

The cron job runs every 2 minutes by default, processing 2 valid configurable products per run, skipping products with existing caches or errors. Logs are written to `var/log/system.log`.

### Clear Cache

[](#clear-cache)

- **Via Admin Panel**: Go to **Stores &gt; Configuration &gt; ShopWhizzy &gt; Swatches Cache &gt; Cache Management** and click "Clear All Swatch Cache".
- **Via Observer**: Cache files for a product are cleared automatically on save if the observer is enabled.

Troubleshooting
---------------

[](#troubleshooting)

- **Button Not Working**: Ensure the cron is enabled (`Enable Cron` set to "Yes") and clear JavaScript/cache: ```
    bin/magento cache:clean js
    bin/magento setup:static-content:deploy
    ```
- **Cron Not Running**: Verify Magento's cron is configured: ```
    crontab -l
    ```

    Ensure `var/log/system.log` shows cron activity.
- **Permission Issues**: Check that `var/swatches` is writable by the web server user.
- **JavaScript Errors**: Open browser developer tools (F12) to check for errors in the Console or Network tabs. Ensure `ShopWhizzy_SwatchCache/js/clear-cache.js` loads correctly.
- **ACL Restrictions**: Ensure the admin user has the `ShopWhizzy_SwatchCache::clear_cache` permission in **System &gt; Permissions &gt; User Roles**.

License
-------

[](#license)

This module is licensed under a proprietary license. See the `LICENSE` file or contact ShopWhizzy for details.

Support
-------

[](#support)

For issues or feature requests, contact ShopWhizzy support at  or open an issue on the module's repository (if available).

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance52

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

340d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2630478?v=4)[ShopWhizzy](/maintainers/shopwhizzy)[@shopwhizzy](https://github.com/shopwhizzy)

---

Top Contributors

[![shopwhizzy](https://avatars.githubusercontent.com/u/2630478?v=4)](https://github.com/shopwhizzy "shopwhizzy (3 commits)")

### Embed Badge

![Health badge](/badges/shopwhizzy-magento2-swatchcache/health.svg)

```
[![Health](https://phpackages.com/badges/shopwhizzy-magento2-swatchcache/health.svg)](https://phpackages.com/packages/shopwhizzy-magento2-swatchcache)
```

###  Alternatives

[mollie/magento2

Mollie Payment Module for Magento 2

1131.9M16](/packages/mollie-magento2)[run-as-root/magento2-prometheus-exporter

Magento2 Prometheus Exporter

68357.9k](/packages/run-as-root-magento2-prometheus-exporter)[buckaroo/magento2

Buckaroo Magento 2 extension

32420.3k8](/packages/buckaroo-magento2)[baldwin/magento2-module-url-data-integrity-checker

Magento 2 module which can find potential url related problems in your catalog data

282822.9k](/packages/baldwin-magento2-module-url-data-integrity-checker)[dotdigital/dotdigital-magento2-extension

Dotdigital for Magento 2

50398.5k20](/packages/dotdigital-dotdigital-magento2-extension)[lizardmedia/module-varnish-warmer

Varnish Cache Warmer Magento2 module by Lizard Media

6180.3k](/packages/lizardmedia-module-varnish-warmer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
