Skip to content

Commit 8ee02ee

Browse files
committed
MC-18701: API Attribute Option update creates same value multiple times
1 parent fede048 commit 8ee02ee

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function add($entityType, $attributeCode, $option)
7575
}
7676
}
7777

78-
if (!$this->isAdminStoreLabelUnique($attribute, (string) $options['value'][$optionId][0])) {
78+
if (!$this->isAttributeOptionLabelExists($attribute, (string) $options['value'][$optionId][0])) {
7979
throw new InputException(
8080
__(
8181
'Admin store attribute option label "%1" is already exists.',
@@ -210,17 +210,19 @@ private function setOptionValue(
210210
}
211211

212212
/**
213-
* Checks if the incoming admin store attribute option label is unique.
213+
* Checks if the incoming attribute option label for admin store is already exists.
214214
*
215215
* @param EavAttributeInterface $attribute
216216
* @param string $adminStoreLabel
217+
* @param int $storeId
217218
* @return bool
218219
*/
219-
private function isAdminStoreLabelUnique(
220+
private function isAttributeOptionLabelExists(
220221
EavAttributeInterface $attribute,
221-
string $adminStoreLabel
222+
string $adminStoreLabel,
223+
int $storeId = 0
222224
) :bool {
223-
$attribute->setStoreId(0);
225+
$attribute->setStoreId($storeId);
224226

225227
foreach ($attribute->getSource()->toOptionArray() as $existingAttributeOption) {
226228
if ($existingAttributeOption['label'] === $adminStoreLabel) {

0 commit comments

Comments
 (0)