Skip to content

Commit 2ea738a

Browse files
authored
[troll] MC-39990: Unexpected displayed visual swatch attribute of the Configurable product (#6474)
* MC-39990: Unexpected displayed visual swatch attribute of the Configurable product
1 parent b0934fe commit 2ea738a

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

app/code/Magento/Swatches/Helper/Media.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ public function moveImageFromTmp($file)
176176
} else {
177177
$this->mediaDirectory->renameFile(
178178
$this->mediaConfig->getTmpMediaPath($file),
179-
$this->getAttributeSwatchPath($destinationFile)
179+
$this->mediaDirectory->getDriver()->getRealPathSafety(
180+
$this->getAttributeSwatchPath($destinationFile)
181+
)
180182
);
181183
}
182184

@@ -197,7 +199,7 @@ protected function getUniqueFileName($file)
197199
$file
198200
);
199201
} else {
200-
$destFile = rtrim(dirname($file), '/.') . '/' . \Magento\MediaStorage\Model\File\Uploader::getNewFileName(
202+
$destFile = dirname($file) . '/' . \Magento\MediaStorage\Model\File\Uploader::getNewFileName(
201203
$this->getOriginalFilePath($file)
202204
);
203205
}

app/code/Magento/Swatches/Test/Unit/Helper/MediaTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\Filesystem\Directory\ReadInterface;
1515
use Magento\Framework\Filesystem\Directory\Write;
1616
use Magento\Framework\Filesystem\Directory\WriteInterface;
17+
use Magento\Framework\Filesystem\DriverInterface;
1718
use Magento\Framework\Image;
1819
use Magento\Framework\Image\Factory;
1920
use Magento\Framework\ObjectManagerInterface;
@@ -174,11 +175,20 @@ public function testMoveImageFromTmp()
174175
public function testMoveImageFromTmpNoDb()
175176
{
176177
$this->fileStorageDbMock->method('checkDbUsage')->willReturn(false);
177-
$this->fileStorageDbMock->method('renameFile')->willReturnSelf();
178178
$this->mediaDirectoryMock
179179
->expects($this->atLeastOnce())
180180
->method('getAbsolutePath')
181181
->willReturn('attribute/swatch/f/i/file.tmp');
182+
$this->mediaDirectoryMock
183+
->expects($this->atLeastOnce())
184+
->method('renameFile')
185+
->willReturnSelf();
186+
$driver = $this->getMockBuilder(DriverInterface::class)
187+
->getMockForAbstractClass();
188+
$driver->method('getAbsolutePath')->willReturn('file');
189+
$this->mediaDirectoryMock
190+
->method('getDriver')
191+
->willReturn($driver);
182192
$result = $this->mediaHelperObject->moveImageFromTmp('file.tmp');
183193
$this->assertNotNull($result);
184194
}

dev/tests/integration/testsuite/Magento/Swatches/_files/visual_swatch_attribute_with_different_options_type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
'image-height' => 90,
3131
'image-name' => $imageName,
3232
]);
33-
$imagePath = $swatchesMedia->moveImageFromTmp($imageName);
33+
$imagePath = substr($swatchesMedia->moveImageFromTmp($imageName), 1);
3434
$swatchesMedia->generateSwatchVariations($imagePath);
3535

3636
// Add attribute data

0 commit comments

Comments
 (0)