0

Every time if I try to add a new product-brand-name,

I get this error: The value of Admin must be unique

as you can see it here on the photoRalfe Fernando

  • But this happened by update magento from version 2.1.2 to 2.1.3 – Ralfe Jan 3 '17 at 22:42
1

Please reindex and clear your Magento cache and make sure do not put duplicate option value. e.g. There should be "Nokia" only one time in this drop down.

Reindex command : php bin/magento indexer:reindex

  • still the same. – Ralfe Jan 3 '17 at 18:42
  • This was the problem for me. I think that 2.1.3 added in some validation to ensure that multiple matching values were not entered as options. That meant that if duplicates already existed then suddenly you could not save the attribute. The only option is to remove duplicates and then you should be able to save. The good news is that you should not get this issue again because of the additional validation. – Robert Egginton Feb 17 '17 at 12:34
0

Did You try Re-Index ? Use Magento CLI. Run php bin/magento indexer:reindex from project root directory and then try to add it again.

  • Yes, i did it, but everything still the same – Ralfe Jan 3 '17 at 18:36
  • and this happened by update magento from version 2.1.2 to 2.1.3 – Ralfe Jan 3 '17 at 22:42
0

You have duplicate values for attribute option,Run this sql and remove one duplicate record from attribute options in admin then try to save it will defiantly work, Thanks

SELECT *
  FROM eav_attribute_option_value AS a
  INNER JOIN eav_attribute_option AS ao USING (option_id)
  INNER JOIN (
    SELECT b.store_id, b.value_id, b.value, b.option_id, bo.attribute_id
    FROM eav_attribute_option_value AS b
    INNER JOIN eav_attribute_option AS bo USING (option_id)
  ) AS b ON ao.attribute_id = b.attribute_id
WHERE
  a.value_id != b.value_id
  AND a.store_id = b.store_id
  AND a.value = b.value
0

There is bug in Magento. More about: https://github.com/magento/magento2/issues/8202#issuecomment-315986084

Short: Duplicate entries when you upgrade from old Magento to new one (example: 2.1.2 -> 2.1.3). Check databases where are duplicates entries about product attribute.

Core edit (fastest - bad practice):

diff -r ff0ac299b1dc www/vendor/magento/module-catalog/Controller/Adminhtml/Product/Attribute/Validate.php
--- a/www/vendor/magento/module-catalog/Controller/Adminhtml/Product/Attribute/Validate.php    Tue Mar 07 23:25:16 2017 +0100
+++ b/www/vendor/magento/module-catalog/Controller/Adminhtml/Product/Attribute/Validate.php    Wed Mar 08 12:30:27 2017 +0100
@@ -152,7 +152,7 @@
      */
     private function checkUniqueOption(DataObject $response, array $options = null)
     {
-        if (is_array($options) && !$this->isUniqueAdminValues($options['value'], $options['delete'])) {
+        if (is_array($options) && !$this->isUniqueAdminValues(@(array)$options['value'], $options['delete'])) {
             $this->setMessageToResponse($response, [__('The value of Admin must be unique.')]);
             $response->setError(true);
         }

Fix database (not tested, better option)

BEFORE PASTE: Change ID from "CHANGE_THIS" to specific attribute id which cause problem. Get it from url: ...catalog/product_attribute/edit/attribute_id/115/key/...

SELECT * FROM `eav_attribute_option_value` where option_id in (SELECT option_id FROM `eav_attribute_option` where attribute_id=CHANGE_THIS) ORDER BY `eav_attribute_option_value`.`value` ASC

SOURCE AND CREDITS: https://github.com/magento/magento2/issues/8202

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.