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

Enforce product SKU uniqueness at the database layer. #230

wants to merge 1 commit into from
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

@@ -0,0 +1,10 @@
##Make product SKU a unique field in a product table.
For now, responsibility for the uniqueness of SKU attribute is part of application logic.
As a result, this logic may be inconsistent per product creation scenarios.
For instance, import may have another set of validations rules than product creation through the admin panel.

To ensure uniqueness of product SKU in the Magento database, we should add a unique constraint for the SKU field in the product table.

For backward compatibility, we can enforce SKU uniqueness through the database patch. Product with a higher ID will keep an SKU. All duplicates will get a unique suffix. For transparency, the merchant will get a report of duplicates that were resolved by the patch.

This comment has been minimized.

Copy link

Vinai Aug 16, 2019

A dry-run option to generate the report before applying the patch would be really helpful.

Another option is enforcing the uniqueness check for fresh installations only. With this case, existing merchants will be responsible to resolve SKU collisions manually prior to the upgrade.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.