Enforce product SKU uniqueness at the database layer. #230
|@@ -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.|
|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.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews.