craftcms / commerce

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

[4.x]: SKU already exists when trying to save the same product on a new site. #3124

Closed TomDeSmet closed 1 year ago

TomDeSmet commented 1 year ago

What happened?

Description

I added new sites to an existing Craft setup. All products were propagated except for the SKU, price and stock fields (see #3125). When I fill in the SKU field with the same SKU as the product has in all other previously existing sites and saving it, I get the error that the SKU already exists.

Steps to reproduce

  1. Add a new site to an existing Craft setup.
  2. Wait for all products to be resaved.
  3. Check a product, the SKU field will be blank.
  4. Fill in the same SKU as the product has for the other sites.
  5. Read the error.

Expected behavior

SKU's should be propagated and if not, the error should not appear as we're saving the product with it's own SKU.

Actual behavior

Throws an error.

Craft CMS version

4.4.5 (also tested on 4.3.10)

Craft Commerce version

4.2.6 (also tested on 4.2.5.1)

PHP version

8.1.16

Operating system and version

MacOS 13.2.1

Database type and version

MySQL 8.0.32

Image driver and version

No response

Installed plugins and versions

-

pdaleramirez commented 1 year ago

I can confirm this is a bug on > 4.2.5, I've tested and it is because of this commit https://github.com/craftcms/commerce/commit/e99910f3e8413cde0b1ac1158264b01603466fcd

TomDeSmet commented 1 year ago

A resave of the products via the CLI "fixes" this as validation is not a concern than it seems.