-
Notifications
You must be signed in to change notification settings - Fork 90
Media Gallery Indexing
Sergii Ivashchenko edited this page Apr 6, 2020
·
1 revision
Media gallery indexing is a process of reflecting media assets located in media storage in the database.
Media gallery data consistency is ensured by updating the information about media gallery assets on each media asset upload and delete operation.
The indexing is required only in the following two situations:
- When Enhanced Media Gallery is enabled (to reflect already existing media assets in the database)
- After manual changes are applied to media storage bypassing the Magento application
There are two stages of media gallery indexing process:
-
media_gallery_assettable is updated on the first stage of indexing -
media_gallery_asset_gridtable is updated on the second stage of indexing
The indexing process includes the following steps
Stage 1
- Scan the media assets storage
- Retrieve the data for each media asset
- Create and save media asset entities to the database. Write the data to
media_gallery_assettable Stage 2 - Retrieve information of media assets from the database
- Retrieve information required for displaying in the media gallery grid from extensions
- Update
media_gallery_asset_gridwith flat data for media gallery grid rendering
There are two triggers for the media gallery indexing process:
-
bin/magento media-gallery:indexconsole command can be used for manual index triggering. The command is implemented byMagento\MediaGalleryUi\Console\Command\IndexAssets - Saving the stores configuration after enabling
Enhanced Media Galleryimplemented byMagento\MediaGalleryUi\Plugin\MediaGalleryIndexerTrigger::afterSaveplugin applied toMagento\Framework\App\Config\Valueclass
-
Magento\MediaGalleryUi\Model\ImagesIndexer::executeprovides the assets storage root path, assets name pattern, indexer options and list of asset indexers configured in the DI -
Magento\MediaGalleryUi\Model\FilesIndexer::executegoes through the file system and callsMagento\MediaGalleryUi\Model\Filesystem\IndexerInterfacefor each file (\SplFileInfo) -
Magento\MediaGalleryUi\Model\Filesystem\IndexerInterfaceis responsible for retrieving any information needed from\SplFileInfoand saving it to the database