Skip to content

Commit 5de9934

Browse files
committed
MAGETWO-57963: The product page doesn't show all the fields for Product Details - for mainline
1 parent 21d4316 commit 5de9934

File tree

6 files changed

+79
-2
lines changed

6 files changed

+79
-2
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ public function execute()
101101
}
102102
$model->save();
103103
$this->messageManager->addSuccess(__('You saved the attribute set.'));
104+
} catch (\Magento\Framework\Exception\AlreadyExistsException $e) {
105+
$this->messageManager->addExceptionMessage(
106+
$e,
107+
__('Attribute group with same code is already exist. Please enter other Group name')
108+
);
109+
$hasError = true;
104110
} catch (\Magento\Framework\Exception\LocalizedException $e) {
105111
$this->messageManager->addError($e->getMessage());
106112
$hasError = true;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Eav\Setup;
8+
9+
use Magento\Framework\Setup\UpgradeSchemaInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
13+
/**
14+
* Upgrade the Eav module DB scheme
15+
*/
16+
class UpgradeSchema implements UpgradeSchemaInterface
17+
{
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
22+
{
23+
$setup->startSetup();
24+
25+
if (version_compare($context->getVersion(), '2.1.0', '<')) {
26+
$this->addUniqueKeyToEavAttributeGroupTable($setup);
27+
}
28+
29+
$setup->endSetup();
30+
}
31+
32+
/**
33+
* @param SchemaSetupInterface $setup
34+
* @return void
35+
*/
36+
protected function addUniqueKeyToEavAttributeGroupTable(SchemaSetupInterface $setup)
37+
{
38+
$setup->getConnection()->addIndex(
39+
$setup->getTable('eav_attribute_group'),
40+
$setup->getIdxName(
41+
'catalog_category_product',
42+
['attribute_set_id', 'attribute_group_code'],
43+
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
44+
),
45+
['attribute_set_id', 'attribute_group_code'],
46+
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
47+
);
48+
}
49+
}

app/code/Magento/Eav/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Eav" setup_version="2.0.0">
9+
<module name="Magento_Eav" setup_version="2.1.0">
1010
<sequence>
1111
<module name="Magento_Store"/>
1212
</sequence>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\DB\Adapter;
7+
8+
/**
9+
* Database duplicate exception
10+
*/
11+
class DuplicateException extends \Zend_Db_Adapter_Exception
12+
{
13+
}

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\DB\Adapter\AdapterInterface;
1515
use Magento\Framework\DB\Adapter\ConnectionException;
1616
use Magento\Framework\DB\Adapter\DeadlockException;
17+
use Magento\Framework\DB\Adapter\DuplicateException;
1718
use Magento\Framework\DB\Adapter\LockWaitException;
1819
use Magento\Framework\DB\Ddl\Table;
1920
use Magento\Framework\DB\ExpressionConverter;
@@ -232,6 +233,8 @@ public function __construct(
232233
1205 => LockWaitException::class,
233234
// SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock
234235
1213 => DeadlockException::class,
236+
// SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
237+
1062 => DuplicateException::class,
235238
];
236239
try {
237240
parent::__construct($config);

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Exception\AlreadyExistsException;
1111
use Magento\Framework\Exception\LocalizedException;
1212
use Magento\Framework\Model\ResourceModel\AbstractResource;
13+
use Magento\Framework\DB\Adapter\DuplicateException;
1314

1415
/**
1516
* Abstract resource model class
@@ -409,7 +410,12 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
409410
}
410411
$this->addCommitCallback([$object, 'afterCommitCallback'])->commit();
411412
$object->setHasDataChanges(false);
412-
} catch (\Exception $e) {
413+
} catch (DuplicateException $e) {
414+
$this->rollBack();
415+
$object->setHasDataChanges(true);
416+
throw new AlreadyExistsException(__('Database duplicate value found'));
417+
}
418+
catch (\Exception $e) {
413419
$this->rollBack();
414420
$object->setHasDataChanges(true);
415421
throw $e;

0 commit comments

Comments
 (0)