Skip to content

Removing option_id from a duplicated option #12773

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
wants to merge 1 commit into from

Conversation

JosephMaxwell
Copy link
Contributor

@JosephMaxwell JosephMaxwell commented Dec 15, 2017

Description

When duplicating bundled product, the option_id was not unset. The new option row is inserted, but the option id is not changed. As such, any deletions to the deleted product's options resulted in those same deletions happening on the original product.

Manual testing scenarios

  1. Create a bundle product and assign some products.
  2. Save that bundle product.
  3. Note the option_id in the catalog_product_bundle_option table.
  4. Save and Duplicate the bundle product.
  5. After the bugfix, the option_id value should be different than the option_id for the original product.

Contribution checklist

  • All commits are accompanied by meaningful commit messages
  • Pull request has a meaningful description of its purpose
  • 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)

@orlangur orlangur self-assigned this Dec 18, 2017
$duplicatedBundleOption = clone $bundleOption;
$duplicatedBundleOption->unsetData('option_id');

$duplicatedBundleOptions[$key] = $duplicatedBundleOption;
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Error: Call to undefined method Mock_BundleOptionInterface_3055e245::unsetData() only methods from interface should be used, probably setOptionId(null) or something can do the trick
  2. Please specify typehint for $bundleOptions instead (\Magento\Bundle\Model\Option[])
  3. Codacy is complaining about long names, probably clonedBundleOptions will work
  4. Adopt tests to changed code, write a separate test method to enforce option_id is unset
  5. Use commit amend + force push so that after all changes there is only one commit

@orlangur
Copy link
Contributor

orlangur commented Jan 5, 2018

Hi @JosephMaxwell, please check my earlier comment and apply necessary changes.

@orlangur orlangur added this to the January 2018 milestone Jan 24, 2018
@orlangur
Copy link
Contributor

Closing due to inactivity. Feel free to reach me out anytime later if you wish to continue work on this pull request and it will be reopened.

@orlangur orlangur closed this Jan 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants