@@ -316,22 +316,24 @@ public function prepareForCart()
316
316
public function getFormattedOptionValue ($ optionValue )
317
317
{
318
318
if ($ this ->_formattedOptionValue === null ) {
319
- try {
320
- $ value = $ this ->unserializeJsonValue ($ optionValue );
321
-
322
- $ customOptionUrlParams = $ this ->getCustomOptionUrlParams () ? $ this ->getCustomOptionUrlParams () : [
323
- 'id ' => $ this ->getConfigurationItemOption ()->getId (),
324
- 'key ' => $ value ['secret_key ' ]
325
- ];
326
-
327
- $ value ['url ' ] = ['route ' => $ this ->_customOptionDownloadUrl , 'params ' => $ customOptionUrlParams ];
328
-
329
- $ this ->_formattedOptionValue = $ this ->_getOptionHtml ($ value );
330
- $ this ->getConfigurationItemOption ()->setValue ($ this ->serializer ->serialize ($ value ));
331
- return $ this ->_formattedOptionValue ;
332
- } catch (\Exception $ e ) {
333
- return $ optionValue ;
319
+ if ($ optionValue !== 'null ' ) {
320
+ $ value = $ this ->serializer ->unserialize ($ optionValue );
321
+ if ($ value !== null ) {
322
+ $ customOptionUrlParams = $ this ->getCustomOptionUrlParams ()
323
+ ? $ this ->getCustomOptionUrlParams ()
324
+ : [
325
+ 'id ' => $ this ->getConfigurationItemOption ()->getId (),
326
+ 'key ' => $ value ['secret_key ' ]
327
+ ];
328
+
329
+ $ value ['url ' ] = ['route ' => $ this ->_customOptionDownloadUrl , 'params ' => $ customOptionUrlParams ];
330
+
331
+ $ this ->_formattedOptionValue = $ this ->_getOptionHtml ($ value );
332
+ $ this ->getConfigurationItemOption ()->setValue ($ this ->serializer ->serialize ($ value ));
333
+ return $ this ->_formattedOptionValue ;
334
+ }
334
335
}
336
+ return $ optionValue ;
335
337
}
336
338
return $ this ->_formattedOptionValue ;
337
339
}
@@ -402,16 +404,17 @@ public function getPrintableOptionValue($optionValue)
402
404
*/
403
405
public function getEditableOptionValue ($ optionValue )
404
406
{
405
- try {
406
- $ value = $ this ->unserializeJsonValue ($ optionValue );
407
- return sprintf (
408
- ' %s [%d] ' ,
409
- $ this -> _escaper -> escapeHtml ( $ value [ ' title ' ]) ,
410
- $ this ->getConfigurationItemOption ()-> getId ()
411
- );
412
- } catch ( \ Exception $ e ) {
413
- return $ optionValue ;
407
+ if ( $ optionValue !== ' null ' ) {
408
+ $ unserializedValue = $ this ->serializer -> unserialize ($ optionValue );
409
+ if ( $ unserializedValue !== null ) {
410
+ return sprintf (
411
+ ' %s [%d] ' ,
412
+ $ this ->_escaper -> escapeHtml ( $ unserializedValue [ ' title ' ]),
413
+ $ this -> getConfigurationItemOption ()-> getId ()
414
+ );
415
+ }
414
416
}
417
+ return $ optionValue ;
415
418
}
416
419
417
420
/**
@@ -431,15 +434,14 @@ public function parseOptionValue($optionValue, $productOptionValues)
431
434
if (preg_match ('/\[([0-9]+)\]/ ' , $ optionValue , $ matches )) {
432
435
$ confItemOptionId = $ matches [1 ];
433
436
$ option = $ this ->_itemOptionFactory ->create ()->load ($ confItemOptionId );
434
- try {
435
- $ this ->unserializeJsonValue ($ option ->getValue ());
436
- return $ option -> getValue ();
437
- } catch ( \ Exception $ e ) {
438
- return null ;
437
+ if ( $ option -> getValue () !== ' null ' ) {
438
+ $ unserializedValue = $ this ->serializer -> unserialize ($ option ->getValue ());
439
+ if ( $ unserializedValue !== null ) {
440
+ return $ option -> getValue ();
441
+ }
439
442
}
440
- } else {
441
- return null ;
442
443
}
444
+ return null ;
443
445
}
444
446
445
447
/**
@@ -467,11 +469,13 @@ private function unserializeJsonValue($jsonValue)
467
469
*/
468
470
public function prepareOptionValueForRequest ($ optionValue )
469
471
{
470
- try {
471
- return $ this ->unserializeJsonValue ($ optionValue );
472
- } catch (\Exception $ e ) {
473
- return null ;
472
+ if ($ optionValue !== 'null ' ) {
473
+ $ unserializedValue = $ this ->serializer ->unserialize ($ optionValue );
474
+ if ($ unserializedValue !== null ) {
475
+ return $ unserializedValue ;
476
+ }
474
477
}
478
+ return null ;
475
479
}
476
480
477
481
/**
0 commit comments