Skip to content

Commit f2e6fdd

Browse files
committed
MAGETWO-93522: Custom customer attributes don't show in admin unless they're configured to show on frontend
1 parent c224526 commit f2e6fdd

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

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

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -307,45 +307,17 @@ protected function getAttributesMeta(Type $entityType)
307307
return $meta;
308308
}
309309

310-
/**
311-
* Check whether the specific attribute can be shown in form: customer registration, customer edit, etc...
312-
*
313-
* @param Attribute $customerAttribute
314-
* @return bool
315-
*/
316-
private function canShowAttributeInForm(AbstractAttribute $customerAttribute)
317-
{
318-
$isRegistration = $this->context->getRequestParam($this->getRequestFieldName()) === null;
319-
320-
if ($customerAttribute->getEntityType()->getEntityTypeCode() === 'customer') {
321-
return is_array($customerAttribute->getUsedInForms()) &&
322-
(
323-
(in_array('customer_account_create', $customerAttribute->getUsedInForms()) && $isRegistration) ||
324-
(in_array('customer_account_edit', $customerAttribute->getUsedInForms()) && !$isRegistration)
325-
);
326-
} else {
327-
return is_array($customerAttribute->getUsedInForms()) &&
328-
in_array('customer_address_edit', $customerAttribute->getUsedInForms());
329-
}
330-
}
331-
332310
/**
333311
* Detect can we show attribute on specific form or not
334312
*
335313
* @param Attribute $customerAttribute
336314
* @return bool
337315
*/
338-
private function canShowAttribute(AbstractAttribute $customerAttribute)
316+
private function canShowAttribute(AbstractAttribute $customerAttribute): bool
339317
{
340-
$userDefined = (bool) $customerAttribute->getIsUserDefined();
341-
if (!$userDefined) {
342-
return $customerAttribute->getIsVisible();
343-
}
344-
345-
$canShowOnForm = $this->canShowAttributeInForm($customerAttribute);
346-
347-
return ($this->allowToShowHiddenAttributes && $canShowOnForm) ||
348-
(!$this->allowToShowHiddenAttributes && $canShowOnForm && $customerAttribute->getIsVisible());
318+
return $this->allowToShowHiddenAttributes && (bool) $customerAttribute->getIsUserDefined()
319+
? true
320+
: (bool) $customerAttribute->getIsVisible();
349321
}
350322

351323
/**

0 commit comments

Comments
 (0)