Skip to content
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

Update variant SKU and title before save instead of before validation #3297

Conversation

johnnynotsolucky
Copy link
Contributor

Description

A variants title and SKU are generated automatically based on their respective templates. For this to work correctly when writing code against Commerce APIs and not using validation, we need to ensure that those two side-effects are moved out of validation otherwise they will never be updated correctly without a CLI or CP invoked resave of a product.

This PR removes the updateTitleand updateSku functions to the beforeSave function so that validation of a variant isn't required to generate those two fields data.

Related issues

@johnnynotsolucky johnnynotsolucky requested a review from a team as a code owner October 12, 2023 15:59
@lukeholder
Copy link
Member

lukeholder commented Oct 17, 2023

Thanks for reporting this.

Instead of doing this only before saving, we have decided to do it in addition to before validation. See 75f4a0a.

This means we ensure that it is generated in both cases.

This doesn't break anything since the SKU will not be generated again if it already exists.

This will be in the next release and I will comment here once released. Thanks.

@johnnynotsolucky johnnynotsolucky deleted the update-variant-beforesave branch October 17, 2023 09:12
@nfourtythree
Copy link
Contributor

Commerce 4.3.1 has now been released with these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants