22 class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
45 private $mediaDirectory;
111 \
Magento\MediaStorage\Helper\
File\Storage\Database $coreFileStorageDatabase,
115 \
Magento\Framework\Escaper $escaper,
118 Json $serializer =
null 120 $this->_itemOptionFactory = $itemOptionFactory;
121 $this->_urlBuilder = $urlBuilder;
122 $this->_escaper = $escaper;
123 $this->_coreFileStorageDatabase = $coreFileStorageDatabase;
131 parent::__construct($checkoutSession, $scopeConfig,
$data);
153 if (isset($optionInfo[
'option_value'])) {
155 }
elseif (isset($optionInfo[
'value'])) {
156 return $optionInfo[
'value'];
159 return $optionInfo[
'value'];
179 return new \Magento\Framework\DataObject();
196 $optionActionKey =
'options_' .
$optionId .
'_file_action';
197 if (
$buyRequest->getData($optionActionKey) ==
'save_old') {
199 $currentConfig = $processingParams->getCurrentConfig();
200 if ($currentConfig) {
219 $this->_checkoutSession->setUseNotice(
false);
221 $this->setIsValid(
true);
241 $value = $this->validatorInfo->setUseQuotePath($this->getUseQuotePath())
243 $this->setUserValue(
$value);
246 $this->setIsValid(
false);
255 $this->setUserValue(
$value);
256 }
catch (ProductException $e) {
257 switch ($this->getProcessMode()) {
258 case \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_FULL:
261 "The product's required option(s) weren't entered. " 262 .
"Make sure the options are entered and try again." 267 $this->setUserValue(
null);
271 $this->setUserValue(
null);
273 $this->setIsValid(
false);
277 $this->setUserValue(
null);
298 if ($this->getIsValid() && $this->getUserValue() !==
null) {
299 $value = $this->getUserValue();
310 if (is_array($requestOptions)) {
318 $optionActionKey =
'options_' .
$optionId .
'_file_action';
332 if ($this->_formattedOptionValue ===
null) {
337 $customOptionUrlParams = $this->getCustomOptionUrlParams()
338 ? $this->getCustomOptionUrlParams()
341 'key' =>
$value[
'secret_key']
365 $urlRoute = !empty(
$value[
'url'][
'route']) ?
$value[
'url'][
'route'] :
'';
366 $urlParams = !empty(
$value[
'url'][
'params']) ?
$value[
'url'][
'params'] :
'';
370 '<a href="%s" target="_blank">%s</a> %s',
372 $this->_escaper->escapeHtml(
$title),
376 throw new LocalizedException(
__(
'The file options format is invalid. Use a correct format and try again.'));
391 return $this->serializer->unserialize(
$value);
418 $unserializedValue = $this->serializer->unserialize(
$optionValue);
419 if ($unserializedValue !==
null) {
422 $this->_escaper->escapeHtml($unserializedValue[
'title']),
443 if (preg_match(
'/\[([0-9]+)\]/',
$optionValue, $matches)) {
444 $confItemOptionId = $matches[1];
445 $option = $this->_itemOptionFactory->create()->load($confItemOptionId);
446 if ($this->serializer->unserialize(
$option->getValue()) !==
null) {
461 $unserializedValue = $this->serializer->unserialize(
$optionValue);
462 if ($unserializedValue !==
null) {
463 return $unserializedValue;
477 $value = $this->serializer->unserialize($quoteOption->getValue());
478 if (!isset(
$value[
'quote_path'])) {
479 throw new \Exception();
481 $quotePath =
$value[
'quote_path'];
482 $orderPath =
$value[
'order_path'];
484 if (!$this->mediaDirectory->isFile($quotePath) || !$this->mediaDirectory->isReadable($quotePath)) {
485 throw new \Exception();
488 if ($this->_coreFileStorageDatabase->checkDbUsage()) {
489 $this->_coreFileStorageDatabase->copyFile(
490 $this->mediaDirectory->getAbsolutePath($quotePath),
491 $this->mediaDirectory->getAbsolutePath($orderPath)
494 $this->mediaDirectory->copyFile($quotePath, $orderPath);
510 $this->_customOptionDownloadUrl =
$url;
523 return $this->_urlBuilder->getUrl($route,
$params);
534 $sizes =
$value[
'width'] .
' x ' .
$value[
'height'] .
' ' .
__(
'px.');
__construct(\Magento\Checkout\Model\Session $checkoutSession, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Quote\Model\Quote\Item\OptionFactory $itemOptionFactory, \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase, \Magento\Catalog\Model\Product\Option\Type\File\ValidatorInfo $validatorInfo, \Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile $validatorFile, \Magento\Catalog\Model\Product\Option\UrlBuilder $urlBuilder, \Magento\Framework\Escaper $escaper, array $data=[], Filesystem $filesystem=null, Json $serializer=null)
$_coreFileStorageDatabase
elseif(isset( $params[ 'redirect_parent']))
getCustomizedView($optionInfo)
getSkipCheckRequiredOption()
_unserializeValue($value)
getFormattedOptionValue($optionValue)
getPrintableOptionValue($optionValue)
$_customOptionDownloadUrl
validateUserValue($values)
prepareOptionValueForRequest($optionValue)
_getOptionHtml($optionValue)
getEditableOptionValue($optionValue)
parseOptionValue($optionValue, $productOptionValues)
foreach($product->getExtensionAttributes() ->getBundleProductOptions() as $option) $buyRequest
_getOptionDownloadUrl($route, $params)
setCustomOptionDownloadUrl($url)
getConfigurationItemOption()
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
_getCurrentConfigFileInfo()