Skip to content

Fixed Magento2 Attribute option does not validate for existing records before insert #20852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
83b3504
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Jan 31, 2019
5c34961
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Feb 4, 2019
b724fb8
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Feb 4, 2019
fcba9b2
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Feb 5, 2019
9c32184
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Feb 5, 2019
2bacf70
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Feb 20, 2019
2a06efc
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Feb 21, 2019
f8750f8
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Feb 25, 2019
1a22392
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Feb 26, 2019
259c42f
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Feb 27, 2019
f5ee546
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Feb 27, 2019
d863313
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Mar 4, 2019
dfd1171
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Mar 4, 2019
cc776ed
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Mar 4, 2019
17d36dd
Fixed Magento2 Attribute option does not validate for existing record…
ravi-chandra3197 Apr 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions app/code/Magento/Eav/Setup/EavSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,14 +929,26 @@ public function addAttributeOption($option)
}
}
} elseif (isset($option['values'])) {
foreach ($option['values'] as $sortOrder => $label) {
// add option
$data = ['attribute_id' => $option['attribute_id'], 'sort_order' => $sortOrder];
$this->setup->getConnection()->insert($optionTable, $data);
$intOptionId = $this->setup->getConnection()->lastInsertId($optionTable);

$data = ['option_id' => $intOptionId, 'store_id' => 0, 'value' => $label];
$this->setup->getConnection()->insert($optionValueTable, $data);
foreach ($option['values'] as $sortOrder => $label) {
$select = $this->setup->getConnection()->select()->from(['optionTable' => $optionTable])->join(
['optionValueTable' => $optionValueTable],
'optionTable.option_id = optionValueTable.option_id'
)->where(
'optionTable.attribute_id =?', $option['attribute_id']
)->where(
'optionValueTable.value = ?',$label
);
$row = $this->setup->getConnection()->fetchRow($select);

if (!$row) {
// add option
$data = ['attribute_id' => $option['attribute_id'], 'sort_order' => $sortOrder];
$this->setup->getConnection()->insert($optionTable, $data);
$intOptionId = $this->setup->getConnection()->lastInsertId($optionTable);

$data = ['option_id' => $intOptionId, 'store_id' => 0, 'value' => $label];
$this->setup->getConnection()->insert($optionValueTable, $data);
}
}
}
}
Expand Down