diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 142b7406cf2a4..08f39101b3237 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -183,6 +183,11 @@ class Product extends AbstractEntity private const ERROR_DUPLICATE_URL_KEY_BY_CATEGORY = 'duplicatedUrlKeyByCategory'; + /** + * Hide from product page attribute code + */ + public const COL_MEDIA_IMAGE_HIDE = '_media_is_disabled'; + /** * @var array */ @@ -340,7 +345,7 @@ class Product extends AbstractEntity 'thumbnail_label' => 'thumbnail_image_label', self::COL_MEDIA_IMAGE => 'additional_images', '_media_image_label' => 'additional_image_labels', - '_media_is_disabled' => 'hide_from_product_page', + self::COL_MEDIA_IMAGE_HIDE => 'hide_from_product_page', Product::COL_STORE => 'store_view_code', Product::COL_ATTR_SET => 'attribute_set_code', Product::COL_TYPE => 'product_type', @@ -423,7 +428,7 @@ class Product extends AbstractEntity self::COL_MEDIA_IMAGE, '_media_label', '_media_position', - '_media_is_disabled', + self::COL_MEDIA_IMAGE_HIDE ]; /** @@ -1896,6 +1901,7 @@ private function saveProductMediaGalleryPhase( $rowExistingImages += $existingImages[Store::DEFAULT_STORE_ID][$rowSkuNormalized] ?? []; list($rowImages, $rowLabels) = $this->getImagesFromRow($rowData); $imageHiddenStates = $this->getImagesHiddenStates($rowData); + $imageHideColumnExist = array_key_exists(self::COL_MEDIA_IMAGE_HIDE, $rowData); foreach (array_keys($imageHiddenStates) as $image) { //Mark image as uploaded if it exists if (array_key_exists($image, $rowExistingImages)) { @@ -1953,19 +1959,19 @@ private function saveProductMediaGalleryPhase( continue; } $uploadedFileNormalized = ltrim($uploadedFile, '/\\'); + $storeMediaGalleryValueExists = isset($rowStoreMediaGalleryValues[$uploadedFileNormalized]); if (isset($rowExistingImages[$uploadedFileNormalized])) { $currentFileData = $rowExistingImages[$uploadedFileNormalized]; $currentFileData['store_id'] = $storeId; - $storeMediaGalleryValueExists = isset($rowStoreMediaGalleryValues[$uploadedFileNormalized]); - if (array_key_exists($uploadedFile, $imageHiddenStates) - && $currentFileData['disabled'] != $imageHiddenStates[$uploadedFile] - ) { + if ($imageHideColumnExist) { $imagesForChangeVisibility[] = [ - 'disabled' => $imageHiddenStates[$uploadedFile], + 'disabled' => array_key_exists( + $uploadedFile, + $imageHiddenStates + ) ? $imageHiddenStates[$uploadedFile] : '0', 'imageData' => $currentFileData, 'exists' => $storeMediaGalleryValueExists ]; - $storeMediaGalleryValueExists = true; } if (isset($rowLabels[$column][$columnImageKey]) && $rowLabels[$column][$columnImageKey] !== $currentFileData['label'] @@ -2182,7 +2188,7 @@ private function getImagesHiddenStates($rowData) { $statesArray = []; $mappingArray = [ - '_media_is_disabled' => '1' + self::COL_MEDIA_IMAGE_HIDE => '1' ]; foreach ($mappingArray as $key => $value) {