Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know exactly what values need to be set on this object to save correctly? I am thinking rather than cloning here we add a factory that can create the object as needed. We should also consider the cleanup of these objects once we are done with them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That depends on what type of custom option you added I think. So no, don't think you have a predefined list of values that need to be set unless we have factories for each option type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JeroenVanLeusden do you think you could update the code to use a factory rather than a clone and see if this covers all the cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure do, hopefully have some time by the end of this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmanners Code underneath makes saving stop altogether. Am I missing something?
See that a
Magento\Catalog\Model\Product\Option\Value\Repository
is not present, might be an idea to add that or include the saving of custom options inMagento\Catalog\Model\Product\Option\Repository
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @JeroenVanLeusden I would be tempted to add the repository for just working with the option values. Though https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Catalog/Model/Product/Option/Repository.php#L146 does deal with saving of option values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmanners What are you proposing? Don't know what the preferred way is to get this done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @JeroenVanLeusden sorry for the delay. I would say your suggestion of adding the saving of custom options in
Magento\Catalog\Model\Product\Option\Repository
would be a good option for this.