|
8 | 8 |
|
9 | 9 | use Magento\Customer\Api\CustomerRepositoryInterface;
|
10 | 10 | use Magento\Customer\Model\AddressRegistry;
|
| 11 | +use Magento\Customer\Model\ResourceModel\Address\Attribute\Collection as AddressAttributeCollection; |
11 | 12 | use Magento\Customer\Model\ResourceModel\Address\CollectionFactory;
|
12 | 13 | use Magento\Eav\Model\Config;
|
13 | 14 | use Magento\Eav\Model\Entity\Type;
|
@@ -221,21 +222,22 @@ private function getDefaultData(): array
|
221 | 222 | private function getAttributesMeta(Type $entityType): array
|
222 | 223 | {
|
223 | 224 | $meta = [];
|
| 225 | + /** @var AddressAttributeCollection $attributes */ |
| 226 | + $attributes = $entityType->getAttributeCollection(); |
224 | 227 | $customerId = $this->context->getRequestParam('parent_id');
|
225 | 228 | $entityId = $this->context->getRequestParam('entity_id');
|
| 229 | + |
226 | 230 | if (!$customerId && $entityId) {
|
227 | 231 | $customerId = $this->addressRegistry->retrieve($entityId)->getParentId();
|
228 | 232 | }
|
229 |
| - /** @var \Magento\Customer\Model\ResourceModel\Address\Attribute\Collection $sharedCollection */ |
230 |
| - $sharedCollection = $entityType->getAttributeCollection(); |
231 |
| - $collection = clone $sharedCollection; |
| 233 | + |
232 | 234 | if ($customerId) {
|
233 | 235 | $customer = $this->customerRepository->getById($customerId);
|
234 |
| - $collection->setWebsite($customer->getWebsiteId()); |
| 236 | + $attributes->setWebsite($customer->getWebsiteId()); |
235 | 237 | }
|
236 | 238 |
|
237 | 239 | /* @var AbstractAttribute $attribute */
|
238 |
| - foreach ($collection as $attribute) { |
| 240 | + foreach ($attributes as $attribute) { |
239 | 241 | if (\in_array($attribute->getFrontendInput(), $this->bannedInputTypes, true)) {
|
240 | 242 | continue;
|
241 | 243 | }
|
|
0 commit comments