Skip to content

Commit 70f6996

Browse files
committed
ACP2E-3972: Csv product import : Unable to unset a swatch image
1 parent 9e1d008 commit 70f6996

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ImportWithSharedImagesTest.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ protected function tearDown(): void
9696
parent::tearDown();
9797
}
9898

99+
99100
/**
100101
* @return void
101102
*/
102-
public function testHideImageWhenColumnContainsEmptyValue(): void
103+
public function testImportProductsWithSameImages(): void
103104
{
104-
$productSku = 'ABC';
105105
$this->moveImages('magento_image.jpg');
106-
$source = $this->prepareFile('catalog_import_products_with_swatch_image.csv');
106+
$source = $this->prepareFile('catalog_import_products_with_same_images.csv');
107107
$this->updateUploader();
108108
$errors = $this->import->setParameters([
109109
'behavior' => Import::BEHAVIOR_ADD_UPDATE,
@@ -112,11 +112,19 @@ public function testHideImageWhenColumnContainsEmptyValue(): void
112112
->setSource($source)->validateData();
113113
$this->assertEmpty($errors->getAllErrors());
114114
$this->import->importData();
115-
$this->createdProductsSkus[] = $productSku;
115+
$this->createdProductsSkus = ['SimpleProductForTest1', 'SimpleProductForTest2'];
116116
$this->checkProductsImages('/m/a/magento_image.jpg', $this->createdProductsSkus);
117+
}
117118

118-
$this->importDataResource->cleanBunches();
119-
$source = $this->prepareFile('catalog_import_products_without_swatch_image.csv');
119+
/**
120+
* @return void
121+
* @throws NoSuchEntityException
122+
*/
123+
public function testHideImageWhenColumnContainsEmptyValue(): void
124+
{
125+
$productSku = 'ABC';
126+
$this->moveImages('magento_image.jpg');
127+
$source = $this->prepareFile('catalog_import_products_with_swatch_image.csv');
120128
$this->updateUploader();
121129
$errors = $this->import->setParameters([
122130
'behavior' => Import::BEHAVIOR_ADD_UPDATE,
@@ -125,19 +133,11 @@ public function testHideImageWhenColumnContainsEmptyValue(): void
125133
->setSource($source)->validateData();
126134
$this->assertEmpty($errors->getAllErrors());
127135
$this->import->importData();
128-
$this->productRepository->cleanCache();
129-
$product = $this->productRepository->get($productSku);
130-
$images = $product->getMediaGalleryImages();
131-
$this->assertEmpty($images->getItems());
132-
}
136+
$this->createdProductsSkus[] = $productSku;
137+
$this->checkProductsImages('/m/a/magento_image.jpg', $this->createdProductsSkus);
133138

134-
/**
135-
* @return void
136-
*/
137-
public function testImportProductsWithSameImages(): void
138-
{
139-
$this->moveImages('magento_image.jpg');
140-
$source = $this->prepareFile('catalog_import_products_with_same_images.csv');
139+
$this->importDataResource->cleanBunches();
140+
$source = $this->prepareFile('catalog_import_products_without_swatch_image.csv');
141141
$this->updateUploader();
142142
$errors = $this->import->setParameters([
143143
'behavior' => Import::BEHAVIOR_ADD_UPDATE,
@@ -146,8 +146,10 @@ public function testImportProductsWithSameImages(): void
146146
->setSource($source)->validateData();
147147
$this->assertEmpty($errors->getAllErrors());
148148
$this->import->importData();
149-
$this->createdProductsSkus = ['SimpleProductForTest1', 'SimpleProductForTest2'];
150-
$this->checkProductsImages('/m/a/magento_image.jpg', $this->createdProductsSkus);
149+
$this->productRepository->cleanCache();
150+
$product = $this->productRepository->get($productSku);
151+
$images = $product->getMediaGalleryImages();
152+
$this->assertEmpty($images->getItems());
151153
}
152154

153155
/**
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
sku,name,swatch_image,swatch_image_label,attribute_set_code,product_type,categories,product_websites
2-
ABC,abc,magento_image.jpg,testing,Default,simple,Default,base
1+
sku,name,swatch_image,swatch_image_label,attribute_set_code,product_type,product_websites
2+
ABC,abc,magento_image.jpg,testing,Default,simple,base

0 commit comments

Comments
 (0)