What happened
Editors set the default variant via the "Set default variant" card action while the product is in a provisional draft (they had reordered variants first). After Save, the product still shows the previous default. In the database:
commerce_products.defaultVariantId points at the old variant, while the user's provisional draft row points at the new one.
- Both the old and the new variant have
commerce_variants.isDefault = true. We currently have 57 products in this state.
- After applying such a draft,
elements_owners.sortOrder for the canonical product no longer starts at 1 (e.g. 27..52), and on one product the order came out scrambled with gaps.
Setting the default without an open draft, or saving the reorder and the default change as two separate saves, works.
Looks related to #3564 / #3565.
Steps to reproduce
- Open a product with several variants, drag a variant to a new position (provisional draft gets created).
- Use "Set default variant" on another variant.
- Save.
Not reliably reproducible on a clean product for us; it happens for editors working on products that other users also have provisional drafts on.
Expected behavior
The chosen default and the new order are saved, and only one variant is flagged isDefault.
Craft CMS version
5.11.1
Craft Commerce version
5.7.3
PHP version
8.4
Operating system and version
Linux (Ploi)
Database type and version
PostgreSQL 17
Plugins & versions
Custom module (nested element listeners on products/variants)
What happened
Editors set the default variant via the "Set default variant" card action while the product is in a provisional draft (they had reordered variants first). After Save, the product still shows the previous default. In the database:
commerce_products.defaultVariantIdpoints at the old variant, while the user's provisional draft row points at the new one.commerce_variants.isDefault = true. We currently have 57 products in this state.elements_owners.sortOrderfor the canonical product no longer starts at 1 (e.g. 27..52), and on one product the order came out scrambled with gaps.Setting the default without an open draft, or saving the reorder and the default change as two separate saves, works.
Looks related to #3564 / #3565.
Steps to reproduce
Not reliably reproducible on a clean product for us; it happens for editors working on products that other users also have provisional drafts on.
Expected behavior
The chosen default and the new order are saved, and only one variant is flagged
isDefault.Craft CMS version
5.11.1
Craft Commerce version
5.7.3
PHP version
8.4
Operating system and version
Linux (Ploi)
Database type and version
PostgreSQL 17
Plugins & versions
Custom module (nested element listeners on products/variants)