Skip to content

Commit 6a51338

Browse files
author
Oleksii Korshenko
authored
MAGETWO-80716: Fix the remove of all images in the catalog #11148
2 parents b427bce + cba0f23 commit 6a51338

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/code/Magento/Catalog/Model/Product/Gallery/UpdateHandler.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ protected function processDeletedImages($product, array &$images)
2929
if (!empty($image['removed'])) {
3030
if (!empty($image['value_id']) && !isset($picturesInOtherStores[$image['file']])) {
3131
$recordsToDelete[] = $image['value_id'];
32-
// only delete physical files if they are not used by any other products
33-
if (!($this->resourceModel->countImageUses($image['file']) > 1)) {
32+
$catalogPath = $this->mediaConfig->getBaseMediaPath();
33+
$isFile = $this->mediaDirectory->isFile($catalogPath . $image['file']);
34+
// only delete physical files if they are not used by any other products and if this file exists
35+
if (!($this->resourceModel->countImageUses($image['file']) > 1) && $isFile) {
3436
$filesToDelete[] = ltrim($image['file'], '/');
3537
}
3638
}

0 commit comments

Comments
 (0)