Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 9778bfb

Browse files
committed
Fix the correct removal of the images and the removal of all images in the catalog.
1 parent eba2fbd commit 9778bfb

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)