From 7803eed11f8bf490bf8905ab0577091c7e782156 Mon Sep 17 00:00:00 2001 From: Umar Date: Thu, 25 Jan 2018 13:15:48 +0500 Subject: [PATCH 1/3] product images while exporting does not override previous image having same name in other folder --- app/code/Magento/CatalogImportExport/Model/Import/Product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index cf8707b472156..58e2b13b192aa 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -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; From 0c6120e53a5676bfce884b6d77d9bed2f156adca Mon Sep 17 00:00:00 2001 From: David Manners Date: Fri, 16 Feb 2018 15:14:44 +0000 Subject: [PATCH 2/3] magento-engcom/import-export-improvements#50: exclude the image attributes from the product test, - this is done as the image paths are now being rewritten and are already covered in the import/export tests --- .../Magento/CatalogImportExport/Model/ProductTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php index a118ae99d8a1f..b6fcb807ebf28 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php @@ -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' => [ From 768d1d72b06471a91b7bf7eb8984ffe0a816b4a0 Mon Sep 17 00:00:00 2001 From: David Manners Date: Thu, 22 Feb 2018 11:20:45 +0000 Subject: [PATCH 3/3] magento-engcom/import-export-improvements#50: use the assertEqualsSpecificAttributes to check images contain the same name - when importing files with the same name will now be renamed for this reason we check names are similar now --- .../CatalogImportExport/Model/ProductTest.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php index b6fcb807ebf28..186c6b8a92bb1 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php @@ -140,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()); + } + } }