Skip to content

[Backport 2.1-develop] Correctly save Product Custom Option values #13570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

JeroenVanLeusden
Copy link
Member

@JeroenVanLeusden JeroenVanLeusden commented Feb 8, 2018

Description

Backport of #13569

This occurred because the same value object is used for saving all values. After the save updateStoredData() is called and is used in prepareDataForUpdate().

protected function prepareDataForUpdate($object)
{
$data = $object->getData();
foreach ($object->getStoredData() as $key => $value) {
if (array_key_exists($key, $data) && $data[$key] === $value) {
unset($data[$key]);
}
}
$dataObject = clone $object;
$dataObject->setData($data);
$data = $this->_prepareDataForTable($dataObject, $this->getMainTable());
unset($data[$this->getIdFieldName()]);
unset($dataObject);
return $data;
}

Fixed Issues (if relevant)

  1. Custom option values do not save correctly #5067: Custom option values do not save correctly

Manual testing scenarios

  1. Install module ReachDigital_CustomOption.zip
  2. An extra column as added to the Product Custom Options (http://cloud.h-o.nl/pP3N).
  3. Uncheck all Changes Appearance checkboxes and save product.
  4. Only the first checkbox is saved.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@paales paales added the Partner: Reach Digital Pull Request is created by partner Reach Digital label May 8, 2018
@larsroettig larsroettig requested a review from dmanners May 9, 2018 19:24
@JeroenVanLeusden JeroenVanLeusden deleted the patch-6 branch July 15, 2018 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Partner: Reach Digital Pull Request is created by partner Reach Digital Release Line: 2.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants