Skip to content

Commit

Permalink
Throw exception when attribute doesn't exitst
Browse files Browse the repository at this point in the history
  • Loading branch information
AydinHassan committed Dec 22, 2016
1 parent 010156f commit ed132d0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions 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 All @@ -1020,10 +1026,15 @@ 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',
$this->getAttributeId($entityTypeId, $id),
$attributeId,
$field,
$value
);
Expand Down

0 comments on commit ed132d0

Please sign in to comment.