Skip to content

Commit f7fe8c4

Browse files
authored
ENGCOM-7244: Customer attribute frontend labels not using the store label values on the frontend #27064
2 parents 4362b95 + d90dc8a commit f7fe8c4

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

app/code/Magento/Customer/Block/DataProviders/AddressAttributeData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getFrontendLabel(string $attributeCode): string
5252
{
5353
try {
5454
$attribute = $this->addressMetadata->getAttributeMetadata($attributeCode);
55-
$frontendLabel = $attribute->getFrontendLabel();
55+
$frontendLabel = $attribute->getStoreLabel() ?: $attribute->getFrontendLabel();
5656
} catch (NoSuchEntityException $e) {
5757
$frontendLabel = '';
5858
}

dev/tests/integration/testsuite/Magento/Customer/Block/Form/RegisterTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@ public function testFaxEnabled(): void
138138
$this->assertStringContainsString('title="Fax"', $block->toHtml());
139139
}
140140

141+
/**
142+
* @magentoDataFixture Magento/Customer/_files/attribute_city_store_label_address.php
143+
*/
144+
public function testCityWithStoreLabel(): void
145+
{
146+
/** @var \Magento\Customer\Block\Form\Register $block */
147+
$block = Bootstrap::getObjectManager()->create(
148+
Register::class
149+
)->setTemplate('Magento_Customer::form/register.phtml')
150+
->setShowAddressFields(true);
151+
$this->setAttributeDataProvider($block);
152+
153+
$this->assertStringNotContainsString('title="City"', $block->toHtml());
154+
$this->assertStringContainsString('title="Suburb"', $block->toHtml());
155+
}
156+
141157
/**
142158
* @inheritdoc
143159
*/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
//@codingStandardsIgnoreFile
7+
/** @var \Magento\Customer\Model\Attribute $model */
8+
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class);
9+
/** @var \Magento\Store\Model\StoreManagerInterface $storeManager */
10+
$storeManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\StoreManager::class);
11+
$model->loadByCode('customer_address', 'city');
12+
$storeLabels = $model->getStoreLabels();
13+
$stores = $storeManager->getStores();
14+
/** @var \Magento\Store\Api\Data\WebsiteInterface $website */
15+
foreach ($stores as $store) {
16+
$storeLabels[$store->getId()] = 'Suburb';
17+
}
18+
$model->setStoreLabels($storeLabels);
19+
$model->save();

0 commit comments

Comments
 (0)