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

defaultVariantId not set on initial save #796

Closed
engram-design opened this issue Mar 21, 2019 · 1 comment
Closed

defaultVariantId not set on initial save #796

engram-design opened this issue Mar 21, 2019 · 1 comment
Labels

Comments

@engram-design
Copy link
Contributor

engram-design commented Mar 21, 2019

Description

Refer to craftcms/feed-me#493, but creating a brand new Product with multiple Variants, doesn't seem to set its defaultVariantId value. Subsequently re-saving the product will fix it right up. I'm ensuring that at least one variant has the 'default' switch on (near the matrix-like actions on the right-hand side).

I imagine its to do with the implementation here, where you're indeed sending an SQL update to correctly update the product - but it'll do nothing if the variant has null for an ID - which is what happens for a new variant.

I can see shortly after this code you're saving the variant. Would it be prudent to move this SQL update after the variant has been saved, therefore has an ID?

Additional info

  • Craft version: 3.1.17
  • PHP version: 7.0.31
  • Database driver & version: MySQL
  • Plugins & versions: Commerce 2.1.0.2
@lukeholder
Copy link
Member

Thanks!

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

No branches or pull requests

2 participants