Skip to content

Fix the correct removal of the images and the removal of all images in the catalog. #11150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ protected function getNonAnchorCategoriesSelect(\Magento\Store\Model\Store $stor
*/
protected function isRangingNeeded()
{
return true;
return false;
}

/**
Expand Down
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 exist
if (!($this->resourceModel->countImageUses($image['file']) > 1) && $isFile) {
$filesToDelete[] = ltrim($image['file'], '/');
}
}
Expand Down