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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@ public function build(Product $product, Product $duplicate)

$bundleOptions = $product->getExtensionAttributes()->getBundleProductOptions() ?: [];
$duplicatedBundleOptions = [];

/**
* @var string $key
* @var \Magento\Bundle\Model\Option $bundleOption
*/
foreach ($bundleOptions as $key => $bundleOption) {
$duplicatedBundleOptions[$key] = clone $bundleOption;
$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

}
$duplicate->getExtensionAttributes()->setBundleProductOptions($duplicatedBundleOptions);
}
Expand Down