Skip to content

Commit 1207e1f

Browse files
committed
ACP2E-675: Telephone required on all websites when set to be optional on some
1 parent 9d259d3 commit 1207e1f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

app/code/Magento/Customer/Controller/Adminhtml/Address/Validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ private function validateCustomerAddress(DataObject $response): DataObject
111111
{
112112
$addressForm = $this->formFactory->create('customer_address', 'adminhtml_customer_address');
113113
$formData = $addressForm->extractData($this->getRequest());
114+
114115
$errors = $addressForm->validateData($formData);
115116
if ($errors !== true) {
116117
$messages = $response->hasMessages() ? $response->getMessages() : [];

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Customer\Api\CustomerRepositoryInterface;
1010
use Magento\Customer\Model\AddressRegistry;
11+
use Magento\Customer\Model\ResourceModel\Address\Attribute\Collection as AddressAttributeCollection;
1112
use Magento\Customer\Model\ResourceModel\Address\CollectionFactory;
1213
use Magento\Eav\Model\Config;
1314
use Magento\Eav\Model\Entity\Type;
@@ -221,21 +222,22 @@ private function getDefaultData(): array
221222
private function getAttributesMeta(Type $entityType): array
222223
{
223224
$meta = [];
225+
/** @var AddressAttributeCollection $attributes */
226+
$attributes = $entityType->getAttributeCollection();
224227
$customerId = $this->context->getRequestParam('parent_id');
225228
$entityId = $this->context->getRequestParam('entity_id');
229+
226230
if (!$customerId && $entityId) {
227231
$customerId = $this->addressRegistry->retrieve($entityId)->getParentId();
228232
}
229-
/** @var \Magento\Customer\Model\ResourceModel\Address\Attribute\Collection $sharedCollection */
230-
$sharedCollection = $entityType->getAttributeCollection();
231-
$collection = clone $sharedCollection;
233+
232234
if ($customerId) {
233235
$customer = $this->customerRepository->getById($customerId);
234-
$collection->setWebsite($customer->getWebsiteId());
236+
$attributes->setWebsite($customer->getWebsiteId());
235237
}
236238

237239
/* @var AbstractAttribute $attribute */
238-
foreach ($collection as $attribute) {
240+
foreach ($attributes as $attribute) {
239241
if (\in_array($attribute->getFrontendInput(), $this->bannedInputTypes, true)) {
240242
continue;
241243
}

0 commit comments

Comments
 (0)