File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
app/code/Magento/Catalog/Model/Product/Attribute Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,17 @@ public function getItems($attributeCode)
40
40
*/
41
41
public function add ($ attributeCode , $ option )
42
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
+ }
43
54
return $ this ->eavOptionManagement ->add (
44
55
\Magento \Catalog \Api \Data \ProductAttributeInterface::ENTITY_TYPE_CODE ,
45
56
$ attributeCode ,
You can’t perform that action at this time.
0 commit comments