We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 619ac30 commit ea7e66cCopy full SHA for ea7e66c
app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php
@@ -40,6 +40,17 @@ public function getItems($attributeCode)
40
*/
41
public function add($attributeCode, $option)
42
{
43
+ /** @var \Magento\Eav\Api\Data\AttributeOptionInterface[] $currentOptions */
44
+ $currentOptions = $this->getItems($attributeCode);
45
+ if (is_array($currentOptions)) {
46
+ array_walk($currentOptions, function (&$attributeOption) {
47
+ /** @var \Magento\Eav\Api\Data\AttributeOptionInterface $attributeOption */
48
+ $attributeOption = $attributeOption->getLabel();
49
+ });
50
+ if (in_array($option->getLabel(), $currentOptions)) {
51
+ return false;
52
+ }
53
54
return $this->eavOptionManagement->add(
55
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
56
$attributeCode,
0 commit comments