Description
Preconditions
A custom attribute is created.
We have different frontend labels for the attribute. Store views with different locale settings exist.
Admin users are speaking different languages and need a localized attribute label.
Steps to reproduce
Create an custom attribute with different frontend labels.
Expected result
There are two possible results:
-
A user can see the specific frontend label of the selected store-view. This could be a problem e.g. the user speaks french and the assigned locale of the store view is in another language.
-
The default frontend label can be translated e.g. with the Magento translation functions. This needs a i18n language file or that we can use the inline translation in admin backend.
Actual result
The default frontend label is used.
Have a look into this method:
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::setupAttributeMeta
.
$meta = $this->arrayManager->set($configPath, [], [
'dataType' => $attribute->getFrontendInput(),
'formElement' => $this->getFormElementsMapValue($attribute->getFrontendInput()),
'visible' => $attribute->getIsVisible(),
'required' => $attribute->getIsRequired(),
'notice' => $attribute->getNote(),
'default' => (!$this->isProductExists()) ? $attribute->getDefaultValue() : null,
'label' => $attribute->getDefaultFrontendLabel(), // <-- This is the line
'code' => $attribute->getAttributeCode(),
'source' => $groupCode,
'scopeLabel' => $this->getScopeLabel($attribute),
'globalScope' => $this->isScopeGlobal($attribute),
'sortOrder' => $sortOrder * self::SORT_ORDER_MULTIPLIER,
]);
At least the translation function should be used:
'label' => __($attribute->getDefaultFrontendLabel()),