The Home for Magento 2 Excellence

Automated build tests for Magento 2 modules. Explore. Evaluate. Elevate. #magento2

1062 Modules
673 Ready
388 Need Help
Vendors 🏆 Leaderboard
Popular Module Actively Maintained v2.0.0 MIT

M2clitools

tnegeli/m2clitools 60

Provides CLI commands to cleanup unused product, category, and swatches media files. Also removes illegal media gallery entries and fixes missing product image references.

86,304
Downloads
Below average
41
GitHub Stars
Above average
7d ago
Last Release
1
Open Issues
Build Passing
Ready to install

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
2 errors , 111 warnings
L0 PHPStan

Release Discipline

Follows SemVer · 100% What is this?

Release history audited up to v2.0.0

Tested on Magento 2.4.9

Recent Test History

Each release is tested against the latest Magento version at that time.

v2.0.0 on Magento 2.4.9
Nov 2, 2026
v1.5.5 on Magento 2.4.9
May 27, 2026
v1.5.5 on Magento 2.4.8-p4
Mar 22, 2026
v1.5.5 on Magento 2.4.8-p3
Dec 26, 2025

Share This Module's Status

M2clitools Magento compatibility status badge

README

Loaded from GitHub

CLI Tools for Magento 2

Various CLI Tools for Magento 2

Available commands:

php bin/magento tnegeli:cleanup-unused-product-media

Use this command to backup (or delete) unused product media from filesystem.

You can use the --dry-run option to just test the result.

You can use the --delete option to remove files, instead of doing a backup.

php bin/magento tnegeli:cleanup-unused-category-media

Use this command to backup (or delete) unused category media from filesystem.

You can use the --dry-run option to just test the result.

You can use the --delete option to remove files, instead of doing a backup.

php bin/magento tnegeli:cleanup-unused-swatches-media

Use this command to backup (or delete) unused swatches media from filesystem.

You can use the --dry-run option to just test the result.

You can use the --delete option to remove files, instead of doing a backup.

php bin/magento tnegeli:cleanup-illegal-product-media

Use this command to identify and remove illegal entries in the media gallery database table, which might break catalog: images:resize process.

You can use the --dry-run option to just test the result and give you a list of value_id entries from the media gallery table which are illegal.

php bin/magento tnegeli:cleanup-illegal-product-media-non-existing-files

Use this command to identify and remove illegal entries in the media gallery database table that have no files on the filesystem, which might break catalog:images:resize process.

You can use the --dry-run option to just test the result and give you a list of value_id entries from the media gallery table which are illegal.

php bin/magento tnegeli:cleanup-illegal-product-image-markers-non-existing-files

Each product is checked for the attribute values of

  • image
  • small_image
  • thumbnail

If a product references a file that does not exist, the reference is removed.

You can use the --dry-run option to just test your database.

Safety checks

The commands tnegeli:cleanup-illegal-product-media-non-existing-files and tnegeli:cleanup-illegal-product-image-markers-non-existing-files abort if the product media directory does not exist, or if not a single referenced file exists. Both usually mean the media files are missing (e.g. an unmounted media directory), not that the database entries are illegal. Use the --force option to remove the entries anyway.

Output verbosity

All commands print one line per affected file or database entry, plus a summary. More details are available via the standard verbosity options:

  • -v: additionally list the image markers that are kept (image markers command)
  • -vv: additionally list every checked file
  • -vvv: additionally list every media value read from the database

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.