diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 6f3dffec4b326..7347dae4cacaf 100755 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -1466,13 +1466,15 @@ protected function _saveProducts() if (!empty($rowData[self::COL_MEDIA_IMAGE]) && is_array($rowData[self::COL_MEDIA_IMAGE])) { $position = array_search($mediaImage, $mediaGalleryImages); foreach ($rowData[self::COL_MEDIA_IMAGE] as $mediaImage) { - $mediaGallery[$rowSku][] = [ - 'attribute_id' => $this->getMediaGalleryAttributeId(), - 'label' => isset($mediaGalleryLabels[$position]) ? $mediaGalleryLabels[$position] : '', - 'position' => $position, - 'disabled' => '', - 'value' => $mediaImage, - ]; + if (!empty($mediaImage)) { + $mediaGallery[$rowSku][] = [ + 'attribute_id' => $this->getMediaGalleryAttributeId(), + 'label' => isset($mediaGalleryLabels[$position]) ? $mediaGalleryLabels[$position] : '', + 'position' => $position, + 'disabled' => '', + 'value' => $mediaImage, + ]; + } } } } @@ -1750,7 +1752,7 @@ protected function _getUploader() $destinationDir = "catalog/product"; $destinationPath = $dirAddon . $DS . $this->_mediaDirectory->getRelativePath($destinationDir); - $this->_mediaDirectory->create($destinationDir); + $this->_mediaDirectory->create($destinationPath); if (!$this->_fileUploader->setDestDir($destinationPath)) { throw new \Magento\Framework\Exception\LocalizedException( __('File directory \'%1\' is not writable.', $destinationPath) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php b/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php index 0de5545a49c10..a78e978d84c6f 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php @@ -302,7 +302,14 @@ public function setDestDir($path) protected function _moveFile($tmpPath, $destPath) { if ($this->_directory->isFile($tmpPath)) { - return $this->_directory->copyFile($tmpPath, $destPath); + $tmpRealPath = $this->_directory->getDriver()->getRealPath( + $this->_directory->getAbsolutePath($tmpPath) + ); + $destinationRealPath = $this->_directory->getDriver()->getRealPath( + $this->_directory->getAbsolutePath($destPath) + ); + $isSameFile = $tmpRealPath === $destinationRealPath; + return $isSameFile ?: $this->_directory->copyFile($tmpPath, $destPath); } else { return false; }