Skip to content

Commit 97c39be

Browse files
author
Sergii Kovalenko
committed
MAGETWO-69521: Customer attribute with "Show on Storefront" set to No does not appear in backend
1 parent f4b640b commit 97c39be

File tree

2 files changed

+407
-37
lines changed

2 files changed

+407
-37
lines changed

app/code/Magento/Customer/Model/Customer/DataProvider.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
4141
*/
4242
const MAX_FILE_SIZE = 2097152;
4343

44-
/**
45-
* Says that data is provided to admin and admin user will see customer account
46-
*/
47-
const ADMIN_SCOPE = "admin";
48-
49-
/**
50-
* Says that data is provided to customer
51-
*/
52-
const FRONTEND_SCOPE = "frontend";
53-
5444
/**
5545
* @var Collection
5646
*/
@@ -138,12 +128,11 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
138128
private $context;
139129

140130
/**
141-
* Enum: can be frontend or admin
142131
* Shows what user is used dataProvider
143132
*
144-
* @var string
133+
* @var bool
145134
*/
146-
private $userScope;
135+
private $allowToShowHiddenAttributes;
147136

148137
/**
149138
* @param string $name
@@ -170,7 +159,7 @@ public function __construct(
170159
ContextInterface $context = null,
171160
array $meta = [],
172161
array $data = [],
173-
$userScope = self::ADMIN_SCOPE
162+
$allowToShowHiddenAttributes = true
174163
) {
175164
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
176165
$this->eavValidationRules = $eavValidationRules;
@@ -180,7 +169,7 @@ public function __construct(
180169
$this->filterPool = $filterPool;
181170
$this->fileProcessorFactory = $fileProcessorFactory ?: $this->getFileProcessorFactory();
182171
$this->context = $context ?: ObjectManager::getInstance()->get(ContextInterface::class);
183-
$this->userScope = $userScope;
172+
$this->allowToShowHiddenAttributes = $allowToShowHiddenAttributes;
184173
$this->meta['customer']['children'] = $this->getAttributesMeta(
185174
$this->eavConfig->getEntityType('customer')
186175
);
@@ -395,8 +384,8 @@ private function canShowAttribute(AbstractAttribute $customerAttribute)
395384
in_array('customer_address_edit', $customerAttribute->getUsedInForms());
396385
}
397386

398-
return ($this->userScope === self::ADMIN_SCOPE && $canShowOnForm) ||
399-
($this->userScope === self::FRONTEND_SCOPE && $canShowOnForm && $customerAttribute->getIsVisible());
387+
return ($this->allowToShowHiddenAttributes && $canShowOnForm) ||
388+
(!$this->allowToShowHiddenAttributes && $canShowOnForm && $customerAttribute->getIsVisible());
400389
}
401390

402391
/**

0 commit comments

Comments
 (0)