Skip to content

Commit 91d61bd

Browse files
#24460: Multiline custom attributes save fix.
1 parent cd3b244 commit 91d61bd

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,13 @@ public function setData($key, $value = null)
281281
$key = $this->_implodeArrayField($key);
282282
} elseif (is_array($value) && $this->isAddressMultilineAttribute($key)) {
283283
$value = $this->_implodeArrayValues($value);
284+
} elseif (self::CUSTOM_ATTRIBUTES === $key && is_array($value)) {
285+
foreach ($value as &$attribute) {
286+
$attribute = is_array($attribute) ? $attribute : $attribute->__toArray();
287+
$attribute = $this->processCustomAttribute($attribute);
288+
}
284289
}
290+
285291
return parent::setData($key, $value);
286292
}
287293

@@ -637,8 +643,8 @@ public function unsRegion()
637643
* Is company required
638644
*
639645
* @return bool
640-
* @since 100.2.0
641646
* @throws \Magento\Framework\Exception\LocalizedException
647+
* @since 100.2.0
642648
*/
643649
protected function isCompanyRequired()
644650
{
@@ -649,8 +655,8 @@ protected function isCompanyRequired()
649655
* Is telephone required
650656
*
651657
* @return bool
652-
* @since 100.2.0
653658
* @throws \Magento\Framework\Exception\LocalizedException
659+
* @since 100.2.0
654660
*/
655661
protected function isTelephoneRequired()
656662
{
@@ -661,11 +667,30 @@ protected function isTelephoneRequired()
661667
* Is fax required
662668
*
663669
* @return bool
664-
* @since 100.2.0
665670
* @throws \Magento\Framework\Exception\LocalizedException
671+
* @since 100.2.0
666672
*/
667673
protected function isFaxRequired()
668674
{
669675
return ($this->_eavConfig->getAttribute('customer_address', 'fax')->getIsRequired());
670676
}
677+
678+
/**
679+
* Unify attribute format.
680+
*
681+
* @param array $attribute
682+
* @return array
683+
*/
684+
private function processCustomAttribute(array $attribute): array
685+
{
686+
if (isset($attribute['attribute_code']) &&
687+
isset($attribute['value']) &&
688+
is_array($attribute['value']) &&
689+
$this->isAddressMultilineAttribute($attribute['attribute_code'])
690+
) {
691+
$attribute['value'] = $this->_implodeArrayValues($attribute['value']);
692+
}
693+
694+
return $attribute;
695+
}
671696
}

0 commit comments

Comments
 (0)