Skip to content

Commit 3c6c140

Browse files
author
fabrizio
committed
Cleaned code
1 parent 96f5c59 commit 3c6c140

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

Console/Command/RemoveUnusedMediaCommand.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ class RemoveUnusedMediaCommand extends Command
1717
{
1818
private const OPTION_DRY_RUN = 'dry-run';
1919
private const OPTION_INCLUDING_CACHE = 'including-cache';
20-
2120
private const OPTION_ONLY_CACHE = 'only-cache';
22-
2321
private const OPTION_INCLUDING_RELATION_ENTITY = 'including-relation';
24-
2522
private const OPTION_FORCE = 'force';
2623
private const COMMAND_NAME_EAV_MEDIA_REMOVE_UNUSED = 'eav:media:remove-unused';
2724

@@ -79,21 +76,18 @@ public function execute(InputInterface $input, OutputInterface $output): int
7976
}
8077

8178
$imageDir = $this->getImageDir();
82-
8379
$connection = $this->resourceConnection->getConnection('core_read');
8480
$mediaGalleryTable = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery');
8581

8682
$directoryIterator = new RecursiveDirectoryIterator($imageDir);
8783

8884
$imagesToKeep = $connection->fetchCol('SELECT value FROM ' . $mediaGalleryTable);
8985

90-
// begin new code
9186
if ($deleteNotInRelation) {
9287
$mediaGalleryToEntityTable = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_to_entity');
9388
$sql='SELECT value FROM ' . $mediaGalleryTable. ' where value_id IN (SELECT value_id from '.$mediaGalleryToEntityTable.')';
9489
$imagesToKeep = $connection->fetchCol($sql);
9590
}
96-
// end
9791

9892
foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
9993
// Directory guard
@@ -181,28 +175,24 @@ protected function configure(): void
181175
{
182176
$this->setName(self::COMMAND_NAME_EAV_MEDIA_REMOVE_UNUSED);
183177
$this->setDescription('Remove unused product images');
184-
185178
$this->addOption(
186179
self::OPTION_INCLUDING_CACHE,
187180
'c',
188181
null,
189182
'Also clear the ./cache/* entries for the corresponding images'
190183
);
191-
192184
$this->addOption(
193185
self::OPTION_ONLY_CACHE,
194186
'k',
195187
null,
196188
'Clear only the ./cache/* entries for the corresponding images nad not the corresponding images'
197189
);
198-
199190
$this->addOption(
200191
self::OPTION_INCLUDING_RELATION_ENTITY,
201192
'r',
202193
null,
203194
'Also clear the media not in relation table "catalog_product_entity_media_gallery_value_to_entity"'
204195
);
205-
206196
$this->addOption(
207197
self::OPTION_DRY_RUN,
208198
'd',

0 commit comments

Comments
 (0)