Skip to content

Commit c8b348a

Browse files
author
Dmitry Kologrivov
committed
MAGNIMEX-319: Update products: Fix the same images are duplicated in products details
1 parent 1107b63 commit c8b348a

File tree

1 file changed

+10
-4
lines changed
  • app/code/Magento/CatalogImportExport/Model/Import

1 file changed

+10
-4
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,13 +1373,19 @@ protected function _saveProducts()
13731373
$dispersionPath =
13741374
\Magento\Framework\File\Uploader::getDispretionPath($rowData[self::COL_MEDIA_IMAGE]);
13751375
$imageName = preg_replace('/[^a-z0-9\._-]+/i', '', $rowData[self::COL_MEDIA_IMAGE]);
1376-
$fullDispersionPath = $dispersionPath . '/' . $imageName;
1376+
$fullDispersionPath = strtolower($dispersionPath . '/' . $imageName);
13771377
foreach ($this->cachedImages as $image) {
13781378
if (($image['sku'] == $rowData[self::COL_SKU])
1379-
&& (preg_replace('/_[0-9]+/', '', $image['value']) == $fullDispersionPath)
1379+
&& ($image['value'] == $fullDispersionPath)
13801380
) {
13811381
$imageInProductIsSet = true;
1382-
$imageFromProduct = preg_replace('/_[0-9]+/', '', $image['value']);
1382+
$imageFromProduct = $image['value'];
1383+
break;
1384+
} elseif (($image['sku'] == $rowData[self::COL_SKU])
1385+
&& (preg_replace('/_[0-9]?\./', '.', $image['value']) == $fullDispersionPath)
1386+
) {
1387+
$imageInProductIsSet = true;
1388+
$imageFromProduct = preg_replace('/_[0-9]?\./', '.', $image['value']);
13831389
break;
13841390
} elseif (in_array($fullDispersionPath, $image)) {
13851391
$imageIsSet = true;
@@ -1772,7 +1778,7 @@ protected function _getUploader()
17721778
* @param string $fileName
17731779
* @return string
17741780
*/
1775-
protected function _uploadMediaFiles($fileName, $renameFileOff=false)
1781+
protected function _uploadMediaFiles($fileName, $renameFileOff = false)
17761782
{
17771783
try {
17781784
$res = $this->_getUploader()->move($fileName, $renameFileOff);

0 commit comments

Comments
 (0)