craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
219 stars 170 forks source link

[5.x]: New variants become default after applying product draft #3564

Closed AugustMiller closed 2 months ago

AugustMiller commented 3 months ago

What happened?

Description

After creating a variant element and saving its product, two variants can become marked as the "default."

I suspect this is due to the way “primary ownership” works for nested elements—the new variant's primary owner is the product draft, not the canonical product element. When adding multiple new variants to the same product, only one of the new elements is marked as the default.

https://github.com/craftcms/commerce/assets/1895522/0d5fb5c2-9417-4096-b924-0d412b392e5c

Steps to reproduce

  1. Create a product type that allows multiple variants;
  2. Create a variant for that product and save it;
  3. Create one or more additional variants, noting that "default" is checked for both the original variant and one of the new variants;

Expected behavior

The default variant is reconciled based on the canonical product element, not derivatives.

Craft CMS version

5.2.4.1

Craft Commerce version

5.0.11.1

PHP version

8.2.20

Operating system and version

Docker/DDEV

Database type and version

MySQL 8.0.36

Image driver and version

No response

Installed plugins and versions

linear[bot] commented 3 months ago

PT-1912 [5.x]: New variants become default after applying product draft

lukeholder commented 2 months ago

This was fixed and was released in Craft Commerce 5.0.13. Thanks for reporting!