Skip to content

Commit d7f6baa

Browse files
author
Jeroen van Leusden
committed
Correctly save Product Custom Option values
1 parent 2b78994 commit d7f6baa

File tree

1 file changed

+12
-10
lines changed
  • app/code/Magento/Catalog/Model/Product/Option

1 file changed

+12
-10
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,27 +190,29 @@ public function getProduct()
190190
public function saveValues()
191191
{
192192
foreach ($this->getValues() as $value) {
193-
$this->isDeleted(false);
194-
$this->setData(
193+
$optionValue = clone $this;
194+
$optionValue->isDeleted(false);
195+
196+
$optionValue->setData(
195197
$value
196198
)->setData(
197199
'option_id',
198-
$this->getOption()->getId()
200+
$optionValue->getOption()->getId()
199201
)->setData(
200202
'store_id',
201-
$this->getOption()->getStoreId()
203+
$optionValue->getOption()->getStoreId()
202204
);
203205

204-
if ($this->getData('is_delete') == '1') {
205-
if ($this->getId()) {
206-
$this->deleteValues($this->getId());
207-
$this->delete();
206+
if ($optionValue->getData('is_delete') == '1') {
207+
if ($optionValue->getId()) {
208+
$optionValue->deleteValues($optionValue->getId());
209+
$optionValue->delete();
208210
}
209211
} else {
210-
$this->save();
212+
$optionValue->save();
211213
}
212214
}
213-
//eof foreach()
215+
214216
return $this;
215217
}
216218

0 commit comments

Comments
 (0)