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)
4040 */
4141 public function add ($ attributeCode , $ option )
4242 {
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+ }
4354 return $ this ->eavOptionManagement ->add (
4455 \Magento \Catalog \Api \Data \ProductAttributeInterface::ENTITY_TYPE_CODE ,
4556 $ attributeCode ,
You can’t perform that action at this time.
0 commit comments