Skip to content

Commit 91c3376

Browse files
committed
MAGETWO-64465: Investigate and fix post-refactoring issues
- removed unnecessary json-null comparisons
1 parent b94b53c commit 91c3376

File tree

1 file changed

+26
-36
lines changed
  • app/code/Magento/Catalog/Model/Product/Option/Type

1 file changed

+26
-36
lines changed

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

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -315,24 +315,21 @@ public function prepareForCart()
315315
public function getFormattedOptionValue($optionValue)
316316
{
317317
if ($this->_formattedOptionValue === null) {
318-
if ($optionValue !== 'null') {
319-
$value = $this->serializer->unserialize($optionValue);
320-
if ($value !== null) {
321-
$customOptionUrlParams = $this->getCustomOptionUrlParams()
322-
? $this->getCustomOptionUrlParams()
323-
: [
324-
'id' => $this->getConfigurationItemOption()->getId(),
325-
'key' => $value['secret_key']
326-
];
327-
328-
$value['url'] = ['route' => $this->_customOptionDownloadUrl, 'params' => $customOptionUrlParams];
329-
330-
$this->_formattedOptionValue = $this->_getOptionHtml($value);
331-
$this->getConfigurationItemOption()->setValue($this->serializer->serialize($value));
332-
return $this->_formattedOptionValue;
333-
}
318+
$value = $this->serializer->unserialize($optionValue);
319+
if ($value === null) {
320+
return $optionValue;
334321
}
335-
return $optionValue;
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));
336333
}
337334
return $this->_formattedOptionValue;
338335
}
@@ -403,15 +400,13 @@ public function getPrintableOptionValue($optionValue)
403400
*/
404401
public function getEditableOptionValue($optionValue)
405402
{
406-
if ($optionValue !== 'null') {
407-
$unserializedValue = $this->serializer->unserialize($optionValue);
408-
if ($unserializedValue !== null) {
409-
return sprintf(
410-
'%s [%d]',
411-
$this->_escaper->escapeHtml($unserializedValue['title']),
412-
$this->getConfigurationItemOption()->getId()
413-
);
414-
}
403+
$unserializedValue = $this->serializer->unserialize($optionValue);
404+
if ($unserializedValue !== null) {
405+
return sprintf(
406+
'%s [%d]',
407+
$this->_escaper->escapeHtml($unserializedValue['title']),
408+
$this->getConfigurationItemOption()->getId()
409+
);
415410
}
416411
return $optionValue;
417412
}
@@ -433,11 +428,8 @@ public function parseOptionValue($optionValue, $productOptionValues)
433428
if (preg_match('/\[([0-9]+)\]/', $optionValue, $matches)) {
434429
$confItemOptionId = $matches[1];
435430
$option = $this->_itemOptionFactory->create()->load($confItemOptionId);
436-
if ($option->getValue() !== 'null') {
437-
$unserializedValue = $this->serializer->unserialize($option->getValue());
438-
if ($unserializedValue !== null) {
439-
return $option->getValue();
440-
}
431+
if ($this->serializer->unserialize($option->getValue()) !== null) {
432+
return $option->getValue();
441433
}
442434
}
443435
return null;
@@ -451,11 +443,9 @@ public function parseOptionValue($optionValue, $productOptionValues)
451443
*/
452444
public function prepareOptionValueForRequest($optionValue)
453445
{
454-
if ($optionValue !== 'null') {
455-
$unserializedValue = $this->serializer->unserialize($optionValue);
456-
if ($unserializedValue !== null) {
457-
return $unserializedValue;
458-
}
446+
$unserializedValue = $this->serializer->unserialize($optionValue);
447+
if ($unserializedValue !== null) {
448+
return $unserializedValue;
459449
}
460450
return null;
461451
}

0 commit comments

Comments
 (0)