/**
  * Process js Layout of block
  *
  * @param array $jsLayout
  * @return array
  */
 public function process($jsLayout)
 {
     /** @var \Magento\Eav\Api\Data\AttributeInterface[] $attributes */
     $attributes = $this->attributeMetadataDataProvider->loadAttributesCollection('customer_address', 'customer_register_address');
     $elements = [];
     foreach ($attributes as $attribute) {
         if ($attribute->getIsUserDefined()) {
             continue;
         }
         $elements[$attribute->getAttributeCode()] = $this->attributeMapper->map($attribute);
         if (isset($elements[$attribute->getAttributeCode()]['label'])) {
             $label = $elements[$attribute->getAttributeCode()]['label'];
             $elements[$attribute->getAttributeCode()]['label'] = __($label);
         }
     }
     // The following code is a workaround for custom address attributes
     if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children'])) {
         if (!isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'])) {
             $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] = [];
         }
         $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] = array_merge_recursive($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'], $this->processPaymentConfiguration($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['renders']['children'], $elements));
     }
     if (isset($jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'])) {
         $fields = $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'];
         $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'] = $this->merger->merge($elements, 'checkoutProvider', 'shippingAddress', $fields);
     }
     return $jsLayout;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function getAttributes($formCode)
 {
     $attributes = [];
     $attributesFormCollection = $this->attributeMetadataDataProvider->loadAttributesCollection(AddressMetadataInterface::ENTITY_TYPE_ADDRESS, $formCode);
     foreach ($attributesFormCollection as $attribute) {
         $attributes[$attribute->getAttributeCode()] = $this->attributeMetadataConverter->createMetadataAttribute($attribute);
     }
     if (empty($attributes)) {
         throw NoSuchEntityException::singleField('formCode', $formCode);
     }
     return $attributes;
 }
 /**
  * {@inheritdoc}
  */
 public function getAttributes($formCode)
 {
     $attributes = [];
     $attributesFormCollection = $this->attributeMetadataDataProvider->loadAttributesCollection(self::ENTITY_TYPE_CUSTOMER, $formCode);
     foreach ($attributesFormCollection as $attribute) {
         /** @var $attribute \Magento\Customer\Model\Attribute */
         $attributes[$attribute->getAttributeCode()] = $this->attributeMetadataConverter->createMetadataAttribute($attribute);
     }
     if (empty($attributes)) {
         throw NoSuchEntityException::singleField('formCode', $formCode);
     }
     return $attributes;
 }
예제 #4
0
 /**
  * @return array
  */
 private function getAddressAttributes()
 {
     /** @var \Magento\Eav\Api\Data\AttributeInterface[] $attributes */
     $attributes = $this->attributeMetadataDataProvider->loadAttributesCollection('customer_address', 'customer_register_address');
     $elements = [];
     foreach ($attributes as $attribute) {
         $code = $attribute->getAttributeCode();
         if ($attribute->getIsUserDefined()) {
             continue;
         }
         $elements[$code] = $this->attributeMapper->map($attribute);
         if (isset($elements[$code]['label'])) {
             $label = $elements[$code]['label'];
             $elements[$code]['label'] = __($label);
         }
     }
     return $elements;
 }