Skip to content

Commit ea5e9ed

Browse files
author
Oleksandr Iegorov
committed
MC-42420: Magento Admin can not add a Simple Product to the Order by SKU after deleting a Customizable Option (SKU with blank spaces)
1 parent bd27efb commit ea5e9ed

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

app/code/Magento/Catalog/Model/Product.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ public function beforeSave()
883883

884884
$this->getTypeInstance()->beforeSave($this);
885885

886-
$hasOptions = $this->getData('has_options') === "1";
887-
$hasRequiredOptions = $this->getData('required_options') === "1";
886+
$hasOptions = $this->getData('has_options') === "1" && $this->isProductHasOptions();
887+
$hasRequiredOptions = $this->getData('required_options') === "1" && $this->isProductHasOptions();
888888

889889
/**
890890
* $this->_canAffectOptions - set by type instance only
@@ -934,6 +934,21 @@ public function beforeSave()
934934
parent::beforeSave();
935935
}
936936

937+
/**
938+
* Check based on options data
939+
*
940+
* @return bool
941+
*/
942+
private function isProductHasOptions() : bool
943+
{
944+
if ($this->getData('options') === null) {
945+
$result = true;
946+
} else {
947+
$result = is_array($this->getData('options')) && count($this->getData('options')) > 0;
948+
}
949+
return $result;
950+
}
951+
937952
/**
938953
* Check/set if options can be affected when saving product
939954
*

0 commit comments

Comments
 (0)