Skip to content

Commit e1fe677

Browse files
committed
Merge remote-tracking branch 'main/develop' into MAGETWO-52116
2 parents 6d13973 + 7a04197 commit e1fe677

File tree

37 files changed

+516
-429
lines changed

37 files changed

+516
-429
lines changed

app/code/Magento/Catalog/Model/Product/Copier.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ public function copy(\Magento\Catalog\Model\Product $product)
4747
$product->getWebsiteIds();
4848
$product->getCategoryIds();
4949

50+
/** @var \Magento\Catalog\Model\Product $duplicate */
5051
$duplicate = $this->productFactory->create();
5152
$duplicate->setData($product->getData());
53+
$duplicate->setOptions([]);
5254
$duplicate->setIsDuplicate(true);
5355
$duplicate->setOriginalId($product->getEntityId());
5456
$duplicate->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED);

app/code/Magento/Catalog/Model/Product/Option/Type/File/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(
3838
\Magento\Framework\File\Size $fileSize
3939
) {
4040
$this->scopeConfig = $scopeConfig;
41-
$this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
41+
$this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::MEDIA);
4242
$this->fileSize = $fileSize;
4343
}
4444

app/code/Magento/Catalog/Model/Webapi/Product/Option/Type/File/Processor.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
99
use Magento\Framework\Api\Data\ImageContentInterface;
10-
use Magento\Catalog\Model\Product\Option\Type\File\ValidateFactory;
1110
use Magento\Framework\Api\ImageProcessor;
1211
use Magento\Framework\Filesystem;
1312

@@ -20,7 +19,7 @@ class Processor
2019
protected $imageProcessor;
2120

2221
/** @var string */
23-
protected $destinationFolder = '/custom_options/quote';
22+
protected $destinationFolder = 'custom_options/quote';
2423

2524
/**
2625
* @param Filesystem $filesystem
@@ -40,9 +39,8 @@ public function __construct(
4039
*/
4140
protected function saveFile(ImageContentInterface $imageContent)
4241
{
43-
$uri = $this->filesystem->getUri(DirectoryList::MEDIA);
4442
$filePath = $this->imageProcessor->processImageContent($this->destinationFolder, $imageContent);
45-
return $uri . $this->destinationFolder . $filePath;
43+
return $this->destinationFolder . $filePath;
4644
}
4745

4846
/**
@@ -54,8 +52,8 @@ public function processFileContent(ImageContentInterface $imageContent)
5452
{
5553
$filePath = $this->saveFile($imageContent);
5654

57-
$fileAbsolutePath = $this->filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath($filePath);
58-
$fileHash = md5($this->filesystem->getDirectoryRead(DirectoryList::ROOT)->readFile($filePath));
55+
$fileAbsolutePath = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath($filePath);
56+
$fileHash = md5($this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->readFile($filePath));
5957
$imageSize = getimagesize($fileAbsolutePath);
6058
$result = [
6159
'type' => $imageContent->getType(),

app/code/Magento/Catalog/Model/Webapi/Product/Option/Type/File/Validator.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function testCopy()
7979
[
8080
'__wakeup',
8181
'setData',
82+
'setOptions',
8283
'setIsDuplicate',
8384
'setOriginalId',
8485
'setStatus',
@@ -97,6 +98,7 @@ public function testCopy()
9798
);
9899
$this->productFactoryMock->expects($this->once())->method('create')->will($this->returnValue($duplicateMock));
99100

101+
$duplicateMock->expects($this->once())->method('setOptions')->with([]);
100102
$duplicateMock->expects($this->once())->method('setIsDuplicate')->with(true);
101103
$duplicateMock->expects($this->once())->method('setOriginalId')->with(1);
102104
$duplicateMock->expects(

app/code/Magento/Catalog/Test/Unit/Webapi/Product/Option/Type/File/ValidatorTest.php

Lines changed: 0 additions & 223 deletions
This file was deleted.

app/code/Magento/Catalog/etc/webapi_rest/di.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
1010
<preference for="Magento\Catalog\Model\Product\Option\Type\Date" type="Magento\Catalog\Model\Webapi\Product\Option\Type\Date" />
11-
<preference for="Magento\Catalog\Model\Product\Option\Type\File\ValidatorInfo" type="Magento\Catalog\Model\Webapi\Product\Option\Type\File\Validator" />
1211

1312
<type name="Magento\Catalog\Helper\Product\ConfigurationPool">
1413
<arguments>

0 commit comments

Comments
 (0)