Skip to content

Commit 6d5fbd7

Browse files
author
OlgaVasyltsun
committed
MC-35600: The customer creation page not opens without default group selected
1 parent 524f164 commit 6d5fbd7

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Customer\Setup\Patch\Data;
9+
10+
use Magento\Customer\Model\GroupManagement;
11+
use Magento\Customer\Model\Vat;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
15+
/**
16+
* Update default customer group id in customer configuration if it's value is NULL
17+
*/
18+
class UpdateDefaultCustomerGroupInConfig implements DataPatchInterface
19+
{
20+
/**
21+
* @var ModuleDataSetupInterface
22+
*/
23+
private $moduleDataSetup;
24+
25+
/**
26+
* @var GroupManagement
27+
*/
28+
private $groupManagement;
29+
30+
/**
31+
* @param ModuleDataSetupInterface $moduleDataSetup
32+
* @param GroupManagement $groupManagement
33+
*/
34+
public function __construct(
35+
ModuleDataSetupInterface $moduleDataSetup,
36+
GroupManagement $groupManagement
37+
) {
38+
$this->moduleDataSetup = $moduleDataSetup;
39+
$this->groupManagement = $groupManagement;
40+
}
41+
42+
/**
43+
* @inheritDoc
44+
*/
45+
public function apply()
46+
{
47+
$customerGroups = $this->groupManagement->getLoggedInGroups();
48+
$commonGroup = array_shift($customerGroups);
49+
50+
$this->moduleDataSetup->getConnection()->update(
51+
$this->moduleDataSetup->getTable('core_config_data'),
52+
['value' => $commonGroup->getId()],
53+
[
54+
'value is ?' => new \Zend_Db_Expr('NULL'),
55+
'path = ?' => GroupManagement::XML_PATH_DEFAULT_ID,
56+
]
57+
);
58+
59+
return $this;
60+
}
61+
62+
/**
63+
* @inheritDoc
64+
*/
65+
public function getAliases()
66+
{
67+
return [];
68+
}
69+
70+
/**
71+
* @inheritDoc
72+
*/
73+
public static function getDependencies()
74+
{
75+
return [
76+
DefaultCustomerGroupsAndAttributes::class,
77+
];
78+
}
79+
}

app/code/Magento/Customer/etc/adminhtml/system.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,34 +40,39 @@
4040
<field id="default_group" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
4141
<label>Default Group</label>
4242
<source_model>Magento\Customer\Model\Config\Source\Group</source_model>
43+
<validate>required-entry</validate>
4344
</field>
4445
<field id="viv_domestic_group" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
4546
<label>Group for Valid VAT ID - Domestic</label>
4647
<source_model>Magento\Customer\Model\Config\Source\Group</source_model>
4748
<depends>
4849
<field id="auto_group_assign">1</field>
4950
</depends>
51+
<validate>required-entry</validate>
5052
</field>
5153
<field id="viv_intra_union_group" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
5254
<label>Group for Valid VAT ID - Intra-Union</label>
5355
<source_model>Magento\Customer\Model\Config\Source\Group</source_model>
5456
<depends>
5557
<field id="auto_group_assign">1</field>
5658
</depends>
59+
<validate>required-entry</validate>
5760
</field>
5861
<field id="viv_invalid_group" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
5962
<label>Group for Invalid VAT ID</label>
6063
<source_model>Magento\Customer\Model\Config\Source\Group</source_model>
6164
<depends>
6265
<field id="auto_group_assign">1</field>
6366
</depends>
67+
<validate>required-entry</validate>
6468
</field>
6569
<field id="viv_error_group" translate="label" type="select" sortOrder="55" showInDefault="1" showInWebsite="1" showInStore="1">
6670
<label>Validation Error Group</label>
6771
<source_model>Magento\Customer\Model\Config\Source\Group</source_model>
6872
<depends>
6973
<field id="auto_group_assign">1</field>
7074
</depends>
75+
<validate>required-entry</validate>
7176
</field>
7277
<field id="viv_on_each_transaction" translate="label" type="select" sortOrder="56" showInDefault="1" showInWebsite="1" showInStore="1">
7378
<label>Validate on Each Transaction</label>

0 commit comments

Comments
 (0)