@@ -987,6 +987,42 @@ public function isAttributeValid($attrCode, array $attrParams, array $rowData, $
987
987
return true ;
988
988
}
989
989
990
+ /**
991
+ * Create disable image details
992
+ *
993
+ * @param mixed $rowSku
994
+ * @param mixed $column
995
+ * @param mixed $rowExistingImages
996
+ * @param int $storeId
997
+ * @return array|null
998
+ */
999
+ private function disableExistingProductImage (
1000
+ mixed $ rowSku ,
1001
+ mixed $ column ,
1002
+ mixed $ rowExistingImages ,
1003
+ int $ storeId
1004
+ ): ?array {
1005
+ try {
1006
+ $ product = $ this ->productRepository ->get ($ rowSku );
1007
+ if ($ imagePath = $ product ->getData ($ column )) {
1008
+ foreach ($ rowExistingImages as $ existingImage ) {
1009
+ if ($ existingImage ['value ' ] == $ imagePath ) {
1010
+ $ existingImage ['store_id ' ] = $ storeId ;
1011
+
1012
+ return [
1013
+ 'disabled ' => 1 ,
1014
+ 'imageData ' => $ existingImage ,
1015
+ 'exists ' => true
1016
+ ];
1017
+ }
1018
+ }
1019
+ }
1020
+ } catch (NoSuchEntityException ) {
1021
+ }
1022
+
1023
+ return null ;
1024
+ }
1025
+
990
1026
/**
991
1027
* Multiple value separator getter.
992
1028
*
@@ -1682,6 +1718,7 @@ protected function _saveProducts()
1682
1718
$ this ->saveProductToWebsitePhase ($ rowData );
1683
1719
$ this ->saveProductCategoriesPhase ($ rowNum , $ rowData );
1684
1720
$ this ->saveProductTierPricesPhase ($ rowData , $ priceIsGlobal , $ tierPrices );
1721
+ $ imagesToBeRemoved = [];
1685
1722
$ this ->saveProductMediaGalleryPhase (
1686
1723
$ rowNum ,
1687
1724
$ rowData ,
@@ -1918,6 +1955,14 @@ private function saveProductMediaGalleryPhase(
1918
1955
$ imagesByHash = [];
1919
1956
foreach ($ rowImages as $ column => $ columnImages ) {
1920
1957
foreach ($ columnImages as $ columnImageKey => $ columnImage ) {
1958
+ if ($ columnImage == $ this ->getEmptyAttributeValueConstant ()) {
1959
+ if ($ disabledImageDetails =
1960
+ $ this ->disableExistingProductImage ($ rowSku , $ column , $ rowExistingImages , $ storeId )
1961
+ ) {
1962
+ $ imagesForChangeVisibility [] = $ disabledImageDetails ;
1963
+ }
1964
+ continue ;
1965
+ }
1921
1966
$ uploadedFile = $ this ->findImageByColumnImage (
1922
1967
$ productMediaPath ,
1923
1968
$ rowExistingImages ,
0 commit comments