Skip to content

It's possible to create multiple products with the same SKU #7121

@joshdifabio

Description

@joshdifabio

Preconditions

This issue exists in current HEAD in the develop branch (0c6227d). The bug is very apparent from looking at the code. The environment is irrelevant to the issue.

Steps to reproduce

Save a non-existent product more than once simultaneously (e.g. via the REST API).

Expected result

For all but the "winning" save operation (i.e. the one which reaches the database first), either an exception should be raised or updates should be made to the product which was created by the "winning" save operation.

Actual result

Either:
Multiple products are created with the same SKU.
Or:
Multiple products are created with different SKUs (a number is appended to the end of the SKU to make it unique). THIS IS REALLY BAD! If the application detects a duplicate SKU when creating a product then this should be an error! It is critical that products are created with the actual SKU a business uses, and not some other meaningless SKU.

The cause of this issue is very clear when looking at the code [1] [2]. SKU uniqueness is enforced within the application code but not by a constraint in the database. This is totally not robust enough for an application of Magento's importance. Please add database constraints to enforce SKU uniqueness and remove this damaging _generateUniqueSku() method [1].

[1] Uniqueness is enforced in application code
[2] There is no uniqueness constraint in the database schema for SKU

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Framework/WebapiUSE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just CatalogEvent: WroCDContribution day in WroEvent: dmcdindia1Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasebug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions