Skip to content

Commit 346df3f

Browse files
authored
Fix product option files not copying to order dir.
Copy product option file to order directory from quote also when media storage is set to file system, not just database. Also rename _rootDirectory variable to _mediaDirectory, since that's what it is.
1 parent 1507bb1 commit 346df3f

File tree

1 file changed

+13
-8
lines changed
  • app/code/Magento/Catalog/Model/Product/Option/Type

1 file changed

+13
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
3232
protected $_formattedOptionValue = null;
3333

3434
/**
35-
* @var \Magento\Framework\Filesystem\Directory\ReadInterface
35+
* @var \Magento\Framework\Filesystem\Directory\Write
3636
*/
37-
protected $_rootDirectory;
37+
protected $_mediaDirectory;
3838

3939
/**
4040
* Core file storage database
@@ -114,7 +114,7 @@ public function __construct(
114114
$this->_escaper = $escaper;
115115
$this->_coreFileStorageDatabase = $coreFileStorageDatabase;
116116
$this->filesystem = $filesystem ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Filesystem::class);
117-
$this->_rootDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
117+
$this->_mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
118118
$this->validatorInfo = $validatorInfo;
119119
$this->validatorFile = $validatorFile;
120120
$this->serializer = $serializer ? $serializer : ObjectManager::getInstance()->get(Json::class);
@@ -473,13 +473,18 @@ public function copyQuoteToOrder()
473473
$quotePath = $value['quote_path'];
474474
$orderPath = $value['order_path'];
475475

476-
if (!$this->_rootDirectory->isFile($quotePath) || !$this->_rootDirectory->isReadable($quotePath)) {
476+
if (!$this->_mediaDirectory->isFile($quotePath) || !$this->_mediaDirectory->isReadable($quotePath)) {
477477
throw new \Exception();
478478
}
479-
$this->_coreFileStorageDatabase->copyFile(
480-
$this->_rootDirectory->getAbsolutePath($quotePath),
481-
$this->_rootDirectory->getAbsolutePath($orderPath)
482-
);
479+
480+
if ($this->_coreFileStorageDatabase->checkDbUsage()) {
481+
$this->_coreFileStorageDatabase->copyFile(
482+
$this->_mediaDirectory->getAbsolutePath($quotePath),
483+
$this->_mediaDirectory->getAbsolutePath($orderPath)
484+
);
485+
} else {
486+
$this->_mediaDirectory->copyFile($quotePath, $orderPath);
487+
}
483488
} catch (\Exception $e) {
484489
return $this;
485490
}

0 commit comments

Comments
 (0)