Skip to content

natedawg92/CatalogImagesClean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NathanDay CatalogImagesClean Extension

Facts

Description

Magento 2 Module to Clean Catalog Images able to Remove Unused Images from the file system and missing images from the database.

Requirements

  • PHP >= 7.0.0
  • Mage_Core

Compatibility

  • Magento >= 2.0

Installation Instructions

composer config repositories.catalogimagesclean git [email protected]:natedawg92/CatalogImagesClean.git
composer require nathanday/module-catalog-images-clean
php bin/magento module:enable NathanDay_CatalogImagesClean
php bin/magento setup:upgrade

Uninstallation

php bin/magento module:uninstall NathanDay_CatalogImagesClean

Usage

Info Command

php bin/magento catalog:images:info             
Description:
  Information about Unused and/or Missing Images

Usage:
  catalog:images:info [options]

Options:
  -u, --unused          Info on unused product images
  -m, --missing         Info on missing product images
  -t, --duplicate       Info on duplicate product images
  -d, --database        Info on Product images in the Database
  -p, --physical        Info on Product images in the filesystem
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

For Details of Unused, Missing and Duplicated images you do not need to specify any particular flag, if you want information on one or more, specify which flag you require

Sample Output


======================================
Catalog Product Image Information
======================================
53 Unique Images in Database
802 Images in Filesystem
0 Missing Images
749 Unused Images
78 Duplicate Images

for more detailed information add -v to the command and this will print out detailed information specific for each type.

  • in the case of missing images the verbose flag will print a list of files and how many times that file appears in the gallery records.
  • in the case of unused images this will print out a list of images that are present in the filesystem but not in the database
  • in the case of duplicated date, this will print a list of images and what they are a duplicate of

Clean Command

php bin/magento catalog:images:clean

Description:
  Clean Catalog Images, Delete Unused Images in the Filesystem and/or Remove records in the Database for Missing Images

Usage:
  catalog:images:clean [options]

Options:
  -u, --unused          Delete unused product images
  -m, --missing         Remove missing product image Records
  -t, --duplicate       Remove duplicate product images and update database Records
  -d, --dry-run         Dry Run, don't make any changes
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug```

Important: Before utilising this command it is recommended to take a Database and Media Backup.

The clean command will process through all actions to clean up your catalog image files and database records. As with the info command you can specify an individual subset of images to clean e.g. --missing will only action the clean command for missing images.

you can specify the --dry-run flag which will print out what actions would be taken.

The verbose flag -v can also be added to the command to print a list of the Images or database records that will be updated.

When using this command without the --dry-run flag you will shown a recommendation to make an appropriate backup before proceeding at which point you will be asked to confirm you want to proceed.

after this point the command will proceed to Update your database to remove any instances of missing image records and/or Delete files from the media directory that are not associated with any product, depending on your choice of which subsets to clean.

Support

If you have any issues with this extension, open an issue on GitHub.

Contribution

Any contribution is highly appreciated. The best way to contribute code is to open a pull request on GitHub.

Developer

Nathan Day

Licence

OSL - Open Software Licence 3.0

Copyright

(c) 2020 Nathan Day

About

Magento 2 module to Manage and Clean Product Images

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages