diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php b/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php index afe1c7cf9cd08..d36ec24efef0a 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php @@ -40,6 +40,17 @@ public function getItems($attributeCode) */ public function add($attributeCode, $option) { + /** @var \Magento\Eav\Api\Data\AttributeOptionInterface[] $currentOptions */ + $currentOptions = $this->getItems($attributeCode); + if (is_array($currentOptions)) { + array_walk($currentOptions, function (&$attributeOption) { + /** @var \Magento\Eav\Api\Data\AttributeOptionInterface $attributeOption */ + $attributeOption = $attributeOption->getLabel(); + }); + if (in_array($option->getLabel(), $currentOptions)) { + return false; + } + } return $this->eavOptionManagement->add( \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode,