Skip to content

Commit ef51c17

Browse files
author
vnayda
committed
MAGETWO-57963: The product page doesn't show all the fields for Product Details - for mainline
-- fixes after CR
1 parent 78d788f commit ef51c17

File tree

8 files changed

+20
-21
lines changed

8 files changed

+20
-21
lines changed

app/code/Magento/Eav/Model/Entity/AbstractEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
11521152
} catch (DuplicateException $e) {
11531153
$this->rollBack();
11541154
$object->setHasDataChanges(true);
1155-
throw new AlreadyExistsException();
1155+
throw new AlreadyExistsException(__('Unique constraint violation found'), $e);
11561156
} catch (\Exception $e) {
11571157
$this->rollBack();
11581158
$object->setHasDataChanges(true);

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,10 @@
66
namespace Magento\Eav\Model\Entity\Attribute;
77

88
use Magento\Framework\Exception\AlreadyExistsException;
9-
use Magento\Framework\Phrase;
109

1110
/**
12-
* Class AlreadyExistsException
11+
* Class AttributeGroupAlreadyExistsException
1312
*/
1413
class AttributeGroupAlreadyExistsException extends AlreadyExistsException
1514
{
16-
/**
17-
* @param Phrase $phrase
18-
* @param \Exception $cause
19-
*/
20-
public function __construct(Phrase $phrase = null, \Exception $cause = null)
21-
{
22-
if ($phrase === null) {
23-
$phrase = new Phrase('Attribute group with same code is already exist. Please enter other Group name');
24-
}
25-
parent::__construct($phrase, $cause);
26-
}
2715
}

app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ protected function saveNewObject(AbstractModel $object)
143143
try {
144144
return parent::saveNewObject($object);
145145
} catch (DuplicateException $e) {
146-
throw new AttributeGroupAlreadyExistsException();
146+
throw new AttributeGroupAlreadyExistsException(
147+
__(
148+
'Attribute group with same code already exist. Please rename "%1" group',
149+
$object->getAttributeGroupName()
150+
)
151+
);
147152
}
148153
}
149154

@@ -155,7 +160,12 @@ protected function updateObject(AbstractModel $object)
155160
try {
156161
return parent::updateObject($object);
157162
} catch (DuplicateException $e) {
158-
throw new AttributeGroupAlreadyExistsException();
163+
throw new AttributeGroupAlreadyExistsException(
164+
__(
165+
'Attribute group with same code already exist. Please rename "%1" group',
166+
$object->getAttributeGroupName()
167+
)
168+
);
159169
}
160170
}
161171
}

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testAlreadyExistsExceptionProcessingWhenGroupCodeIsDuplicated()
3737
$this->assertNotNull($jsonResponse);
3838
$this->assertEquals(1, $jsonResponse->error);
3939
$this->assertContains(
40-
'Attribute group with same code is already exist. Please enter other Group name',
40+
'Attribute group with same code already exist. Please rename "attribute-group-name" group',
4141
$jsonResponse->message
4242
);
4343
}

lib/internal/Magento/Framework/EntityManager/Operation/Create.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function execute($entity, $arguments = [])
118118
$connection->commit();
119119
} catch (DuplicateException $e) {
120120
$connection->rollBack();
121-
throw new AlreadyExistsException();
121+
throw new AlreadyExistsException(__('Unique constraint violation found'), $e);
122122
} catch (\Exception $e) {
123123
$connection->rollBack();
124124
throw $e;

lib/internal/Magento/Framework/EntityManager/Operation/Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function execute($entity, $arguments = [])
117117
$connection->commit();
118118
} catch (DuplicateException $e) {
119119
$connection->rollBack();
120-
throw new AlreadyExistsException();
120+
throw new AlreadyExistsException(__('Unique constraint violation found'), $e);
121121
} catch (\Exception $e) {
122122
$connection->rollBack();
123123
throw $e;

lib/internal/Magento/Framework/Exception/AlreadyExistsException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AlreadyExistsException extends LocalizedException
1919
public function __construct(Phrase $phrase = null, \Exception $cause = null)
2020
{
2121
if ($phrase === null) {
22-
$phrase = new Phrase('Database duplicate value found');
22+
$phrase = new Phrase('Unique constraint violation found');
2323
}
2424
parent::__construct($phrase, $cause);
2525
}

lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Exception\LocalizedException;
1212
use Magento\Framework\Model\ResourceModel\AbstractResource;
1313
use Magento\Framework\DB\Adapter\DuplicateException;
14+
use Magento\Framework\Phrase;
1415

1516
/**
1617
* Abstract resource model class
@@ -414,7 +415,7 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
414415
} catch (DuplicateException $e) {
415416
$this->rollBack();
416417
$object->setHasDataChanges(true);
417-
throw new AlreadyExistsException();
418+
throw new AlreadyExistsException(new Phrase('Unique constraint violation found'), $e);
418419
} catch (\Exception $e) {
419420
$this->rollBack();
420421
$object->setHasDataChanges(true);

0 commit comments

Comments
 (0)