Skip to content
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

Throw exception when attribute doesn't exitst #7758

Merged
merged 2 commits into from
Jun 13, 2017
Merged
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion app/code/Magento/Eav/Setup/EavSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ public function updateAttribute($entityTypeId, $id, $field, $value = null, $sort
* @param mixed $value
* @param int $sortOrder
* @return $this
* @throws LocalizedException
*/
private function _updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null)
{
Expand Down Expand Up @@ -972,11 +973,15 @@ private function _updateAttribute($entityTypeId, $id, $field, $value = null, $so
return $this;
}
}
$attributeId = $this->getAttributeId($entityTypeId, $id);
if (false === $attributeId) {
throw new LocalizedException(__('Attribute with ID: "%1" does not exist', $id));
}

$this->setup->updateTableRow(
'eav_attribute',
'attribute_id',
$this->getAttributeId($entityTypeId, $id),
$attributeId,
$field,
$value,
'entity_type_id',
Expand All @@ -994,6 +999,7 @@ private function _updateAttribute($entityTypeId, $id, $field, $value = null, $so
* @param string|array $field
* @param mixed $value
* @return $this
* @throws LocalizedException
*/
private function _updateAttributeAdditionalData($entityTypeId, $id, $field, $value = null)
{
Expand Down Expand Up @@ -1022,6 +1028,11 @@ private function _updateAttributeAdditionalData($entityTypeId, $id, $field, $val
return $this;
}
}

$attributeId = $this->getAttributeId($entityTypeId, $id);
if (false === $attributeId) {
throw new LocalizedException(__('Attribute with ID: "%1" does not exist', $id));
}
$this->setup->updateTableRow(
$this->setup->getTable($additionalTable),
'attribute_id',
Expand Down