diff --git a/vendor/magento/module-catalog-import-export/Model/Import/Product.php b/vendor/magento/module-catalog-import-export/Model/Import/Product.php index bec6517e8fb05..596dec406b667 100644 --- a/vendor/magento/module-catalog-import-export/Model/Import/Product.php +++ b/vendor/magento/module-catalog-import-export/Model/Import/Product.php @@ -959,6 +959,43 @@ public function isAttributeValid($attrCode, array $attrParams, array $rowData, $ return true; } + /** + * Create disable image details + * + * @param mixed $rowSku + * @param mixed $column + * @param mixed $rowExistingImages + * @param int $storeId + * @return array|null + */ + private function disableExistingProductImage( + mixed $rowSku, + mixed $column, + mixed $rowExistingImages, + int $storeId + ): ?array { + try { + $product = $this->productRepository->get($rowSku); + if ($imagePath = $product->getData($column)) { + foreach ($rowExistingImages as $existingImage) { + if ($existingImage['value'] == $imagePath) { + $existingImage['store_id'] = $storeId; + + return [ + 'disabled' => 1, + 'imageData' => $existingImage, + 'exists' => true + ]; + } + } + } + } catch (NoSuchEntityException) { + return null; + } + + return null; + } + /** * Multiple value separator getter. * @@ -1875,6 +1912,14 @@ private function saveProductMediaGalleryPhase( $imagesByHash = []; foreach ($rowImages as $column => $columnImages) { foreach ($columnImages as $columnImageKey => $columnImage) { + if ($columnImage == $this->getEmptyAttributeValueConstant()) { + if ($disabledImageDetails = + $this->disableExistingProductImage($rowSku, $column, $rowExistingImages, $storeId) + ) { + $imagesForChangeVisibility[] = $disabledImageDetails; + } + continue; + } $uploadedFile = $this->findImageByColumnImage( $productMediaPath, $rowExistingImages,