Skip to content

Commit d423c9d

Browse files
author
Volodymyr Kublytskyi
committed
MAGETWO-80717: Fix the correct removal of the images and the removal of all images in the catalog #11153
- Merge Pull Request #11153 from raumatbel/magento2:FR#RemoveImages - Merged commits: 1. 6625945 2. 39e06b0 3. 92d8418 4. 8731d97 5. 7715950 6. eba2fbd 7. 9778bfb 8. 5039c94
2 parents ea35a09 + 5039c94 commit d423c9d

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ protected function processDeletedImages($product, array &$images)
3333
if (!empty($image['removed'])) {
3434
if (!empty($image['value_id']) && !isset($picturesInOtherStores[$image['file']])) {
3535
$recordsToDelete[] = $image['value_id'];
36-
// only delete physical files if they are not used by any other products
37-
if (!$this->resourceModel->countImageUses($image['file']) > 1) {
36+
$catalogPath = $this->mediaConfig->getBaseMediaPath();
37+
$isFile = $this->mediaDirectory->isFile($catalogPath . $image['file']);
38+
// only delete physical files if they are not used by any other products and if this file exist
39+
if (!($this->resourceModel->countImageUses($image['file']) > 1) && $isFile) {
3840
$filesToDelete[] = ltrim($image['file'], '/');
3941
}
4042
}

0 commit comments

Comments
 (0)