Skip to content

Commit

Permalink
Correctly save Product Custom Option values
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen van Leusden authored and Jeroen committed Jul 15, 2018
1 parent ce5eacd commit 955fbf2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions app/code/Magento/Catalog/Model/Product/Option/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,27 +202,29 @@ public function getProduct()
public function saveValues()
{
foreach ($this->getValues() as $value) {
$this->isDeleted(false);
$this->setData(
$optionValue = clone $this;
$optionValue->isDeleted(false);

$optionValue->setData(
$value
)->setData(
'option_id',
$this->getOption()->getId()
$optionValue->getOption()->getId()
)->setData(
'store_id',
$this->getOption()->getStoreId()
$optionValue->getOption()->getStoreId()
);

if ($this->getData('is_delete') == '1') {
if ($this->getId()) {
$this->deleteValues($this->getId());
$this->delete();
if ($optionValue->getData('is_delete') == '1') {
if ($optionValue->getId()) {
$optionValue->deleteValues($optionValue->getId());
$optionValue->delete();
}
} else {
$this->save();
$optionValue->save();
}
}
//eof foreach()

return $this;
}

Expand Down

1 comment on commit 955fbf2

@jkiranmai
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not working.

Please sign in to comment.