From 72654c728d7e6f398a281c1f6b30d70a565980d4 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 12 Aug 2017 01:07:56 +0200 Subject: [PATCH] Fixed image renaming feature, which could lead to duplicated file names if using gallery --- .../imageprocessor/imageitattributeemprocessor.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/magmi/plugins/extra/itemprocessors/imageprocessor/imageitattributeemprocessor.php b/magmi/plugins/extra/itemprocessors/imageprocessor/imageitattributeemprocessor.php index 0495593e..8106df41 100644 --- a/magmi/plugins/extra/itemprocessors/imageprocessor/imageitattributeemprocessor.php +++ b/magmi/plugins/extra/itemprocessors/imageprocessor/imageitattributeemprocessor.php @@ -92,7 +92,10 @@ public function handleGalleryTypeAttribute($pid, &$item, $storeid, $attrcode, $a } // use ";" as image separator $images = explode(";", $ivalue); - $imageindex = 0; + + // starting at 1, because otherwise if image renaming is used the main product image is already used for 0. + $imageindex = 1; + // for each image foreach ($images as $imagefile) { // trim image file in case of spaced split @@ -106,7 +109,7 @@ public function handleGalleryTypeAttribute($pid, &$item, $storeid, $attrcode, $a $imagefile = $infolist[0]; } unset($infolist); - $extra=array("store"=>$storeid,"attr_code"=>$attrcode,"imageindex"=>$imageindex == 0 ? "" : $imageindex); + $extra=array("store"=>$storeid,"attr_code"=>$attrcode,"imageindex"=>$imageindex); // copy it from source dir to product media dir $imagefile = $this->copyImageFile($imagefile, $item, $extra); unset($extra); @@ -184,7 +187,7 @@ public function handleImageTypeAttribute($pid, &$item, $storeid, $attrcode, $att $imagefile = trim($ivalue); // else copy image file - $imagefile = $this->copyImageFile($imagefile, $item, array("store"=>$storeid, "attr_code"=>$attrcode)); + $imagefile = $this->copyImageFile($imagefile, $item, array("store"=>$storeid, "attr_code"=>$attrcode,"imageindex"=>0)); $ovalue = $imagefile; // add to gallery as excluded if ($imagefile !== false) {