6
6
7
7
namespace Magento \Catalog \Model \Product \Option \Type ;
8
8
9
+ use Magento \Catalog \Model \Product \Exception as ProductException ;
10
+ use Magento \Catalog \Helper \Product as ProductHelper ;
9
11
use Magento \Framework \App \Filesystem \DirectoryList ;
10
12
use Magento \Framework \Filesystem ;
11
13
use Magento \Framework \Exception \LocalizedException ;
12
- use Magento \Catalog \Model \Product \Exception as ProductException ;
13
14
use Magento \Framework \Serialize \Serializer \Json ;
14
15
use Magento \Framework \App \ObjectManager ;
15
16
@@ -91,6 +92,11 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
91
92
*/
92
93
private $ filesystem ;
93
94
95
+ /**
96
+ * @var ProductHelper
97
+ */
98
+ private $ productHelper ;
99
+
94
100
/**
95
101
* @param \Magento\Checkout\Model\Session $checkoutSession
96
102
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
@@ -103,6 +109,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
103
109
* @param array $data
104
110
* @param Filesystem $filesystem
105
111
* @param Json|null $serializer
112
+ * @param ProductHelper|null $productHelper
106
113
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
107
114
*/
108
115
public function __construct (
@@ -116,7 +123,8 @@ public function __construct(
116
123
\Magento \Framework \Escaper $ escaper ,
117
124
array $ data = [],
118
125
Filesystem $ filesystem = null ,
119
- Json $ serializer = null
126
+ Json $ serializer = null ,
127
+ ProductHelper $ productHelper = null
120
128
) {
121
129
$ this ->_itemOptionFactory = $ itemOptionFactory ;
122
130
$ this ->_urlBuilder = $ urlBuilder ;
@@ -129,6 +137,7 @@ public function __construct(
129
137
$ this ->validatorInfo = $ validatorInfo ;
130
138
$ this ->validatorFile = $ validatorFile ;
131
139
$ this ->serializer = $ serializer ?: ObjectManager::getInstance ()->get (Json::class);
140
+ $ this ->productHelper = $ productHelper ?: ObjectManager::getInstance ()->get (ProductHelper::class);
132
141
parent ::__construct ($ checkoutSession , $ scopeConfig , $ data );
133
142
}
134
143
@@ -223,6 +232,12 @@ public function validateUserValue($values)
223
232
$ this ->setIsValid (true );
224
233
$ option = $ this ->getOption ();
225
234
235
+ if (isset ($ values ['files_prefix ' ])) {
236
+ $ processingParams = ['files_prefix ' => $ values ['files_prefix ' ]];
237
+ $ processingParams = array_merge ($ this ->_getProcessingParams ()->getData (), $ processingParams );
238
+ $ this ->productHelper ->addParamsToBuyRequest ($ this ->getRequest (), $ processingParams );
239
+ }
240
+
226
241
/*
227
242
* Check whether we receive uploaded file or restore file by: reorder/edit configuration or
228
243
* previous configuration with no newly uploaded file
0 commit comments