Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

product images with same name overwrite previous image fix #99

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}
}