Skip to content

Commit

Permalink
MAGETWO-80714: Fix the correct removal of the images and the removal …
Browse files Browse the repository at this point in the history
…of all images in the catalog #11147
  • Loading branch information
vrann authored Oct 4, 2017
2 parents fb173bb + 2dfd4ba commit 4a58f62
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ protected function processDeletedImages($product, array &$images)
if (!empty($image['removed'])) {
if (!empty($image['value_id']) && !isset($picturesInOtherStores[$image['file']])) {
$recordsToDelete[] = $image['value_id'];
// only delete physical files if they are not used by any other products
if (!$this->resourceModel->countImageUses($image['file']) > 1) {
$catalogPath = $this->mediaConfig->getBaseMediaPath();
$isFile = $this->mediaDirectory->isFile($catalogPath . $image['file']);
// only delete physical files if they are not used by any other products and if this file exists
if (!($this->resourceModel->countImageUses($image['file']) > 1) && $isFile) {
$filesToDelete[] = ltrim($image['file'], '/');
}
}
Expand Down

0 comments on commit 4a58f62

Please sign in to comment.