-
Notifications
You must be signed in to change notification settings - Fork 92
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_asset
table is updated on the first stage of indexing -
media_gallery_asset_grid
table 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_asset
table 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_grid
with flat data for media gallery grid rendering
There are two triggers for the media gallery indexing process:
-
bin/magento media-gallery:index
console 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 Gallery
implemented byMagento\MediaGalleryUi\Plugin\MediaGalleryIndexerTrigger::afterSave
plugin applied toMagento\Framework\App\Config\Value
class
-
Magento\MediaGalleryUi\Model\ImagesIndexer::execute
provides the assets storage root path, assets name pattern, indexer options and list of asset indexers configured in the DI -
Magento\MediaGalleryUi\Model\FilesIndexer::execute
goes through the file system and callsMagento\MediaGalleryUi\Model\Filesystem\IndexerInterface
for each file (\SplFileInfo
) -
Magento\MediaGalleryUi\Model\Filesystem\IndexerInterface
is responsible for retrieving any information needed from\SplFileInfo
and saving it to the database