Magento 2.x throws an error message on saving a product that has a unique, required attribute value when that value has been used before by a product that has been deleted.
In other words: the attribute's unique value of a product, remains stored in the database after that product has been deleted.
Say we create a product in M2 admin.
- We have a REQUIRED Custom Attribute "SKU Number" with UNIQUE value "1".
- Save the product and than delete the product and flush cache.
- Create new product in M2 admin.
- Apply required Custom Attribute "SKU Number". Also with value "1" (from deleted product).
It appears that we are now unable to save this newly created product because it uses the unique value of a deleted product. Error message: "Required attribute value must be unique".
IMHO the attribute value in this case is unique because the product that has been using this unique value has been deleted.
Does anybody have an idea about how can I delete the unique value of a custom attribute when it is no longer in use by a product?