Skip to content

Commit

Permalink
fix magento#8846: fix function logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gomencal committed Oct 26, 2017
1 parent c70d5b8 commit 73c4523
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,22 @@ public function getItems($attributeCode)
*/
public function add($attributeCode, $option)
{
/** @var \Magento\Eav\Api\Data\AttributeOptionInterface[] $currentOptions */
$currentOptions = $this->getItems($attributeCode);
array_walk($currentOptions, function (&$attributeOption) {
/** @var \Magento\Eav\Api\Data\AttributeOptionInterface $attributeOption */
$attributeOption = $attributeOption->getLabel();
});
if (!in_array($option->getLabel(), $currentOptions)) {
return $this->eavOptionManagement->add(
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
$attributeCode,
$option
);
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 false;
return $this->eavOptionManagement->add(
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
$attributeCode,
$option
);
}

/**
Expand Down

0 comments on commit 73c4523

Please sign in to comment.