Skip to content

Commit

Permalink
MAGETWO-88240: product images with same name overwrite previous image f…
Browse files Browse the repository at this point in the history
…ix #99

 - Merge Pull Request magento-engcom/import-export-improvements#99 from umarch06/import-export-improvements:50-product-images-import-path-fix
 - Merged commits:
   1. 7803eed
   2. 0c6120e
   3. 768d1d7
  • Loading branch information
magento-engcom-team committed Feb 22, 2018
2 parents c166940 + 768d1d7 commit a2119af
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,7 @@ protected function _saveProducts()
foreach ($rowImages as $column => $columnImages) {
foreach ($columnImages as $columnImageKey => $columnImage) {
if (!isset($uploadedImages[$columnImage])) {
$uploadedFile = $this->uploadMediaFiles($columnImage, true);
$uploadedFile = $this->uploadMediaFiles($columnImage);
$uploadedFile = $uploadedFile ?: $this->getSystemFile($columnImage);
if ($uploadedFile) {
$uploadedImages[$columnImage] = $uploadedFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,16 @@ public function exportImportDataProvider()
'simple-product-image' => [
[
'Magento/CatalogImportExport/Model/Import/_files/media_import_image.php',
'Magento/Catalog/_files/product_with_image.php'
'Magento/Catalog/_files/product_with_image.php',
],
[
'simple',
],
[
"image",
"small_image",
"thumbnail",
"media_gallery"
]
],
'simple-product-crosssell' => [
Expand Down Expand Up @@ -134,4 +140,32 @@ public function importReplaceDataProvider()
{
return $this->exportImportDataProvider();
}

/**
* Fixing https://github.com/magento-engcom/import-export-improvements/issues/50 means that during import images
* can now get renamed for this we need to skip the attribute checking and instead check that the images contain
* the right beginning part of the name. When an image is named "magento_image.jpeg" but there is already an image
* with that name it will now become "magento_image_1.jpeg"
*
* @param \Magento\Catalog\Model\Product $expectedProduct
* @param \Magento\Catalog\Model\Product $actualProduct
*/
protected function assertEqualsSpecificAttributes($expectedProduct, $actualProduct)
{
if (!empty($actualProduct->getImage())
&& !empty($expectedProduct->getImage())
) {
$this->assertContains('magento_image', $actualProduct->getImage());
}
if (!empty($actualProduct->getSmallImage())
&& !empty($expectedProduct->getSmallImage())
) {
$this->assertContains('magento_image', $actualProduct->getSmallImage());
}
if (!empty($actualProduct->getThumbnail())
&& !empty($expectedProduct->getThumbnail())
) {
$this->assertContains('magento_image', $actualProduct->getThumbnail());
}
}
}

0 comments on commit a2119af

Please sign in to comment.