From ed132d007bb9f059b27a7acdefe1bec53b3d6b52 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Mon, 12 Dec 2016 12:47:35 +0100 Subject: [PATCH] Throw exception when attribute doesn't exitst --- app/code/Magento/Eav/Setup/EavSetup.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Eav/Setup/EavSetup.php b/app/code/Magento/Eav/Setup/EavSetup.php index 9ed8ffcdc9375..2444ab9ca61d5 100644 --- a/app/code/Magento/Eav/Setup/EavSetup.php +++ b/app/code/Magento/Eav/Setup/EavSetup.php @@ -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) { @@ -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', @@ -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) { @@ -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 );