How to get the correct label of an attribute on multistore
-
06-05-2021 - |
题
I have a piece of coding which works fine for the default store. Now I created a multistore but this piece of coding is retrieving the default label name, but I want the labelname wich belongs to an other store. this is the coding:
<label class="label"><span><?php echo $attribute->getDefaultFrontendLabel(); ?></span></label>
and that comes from:
<?php /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ ?>
<div class="field ">
<label class="label"><span><?php echo $attribute->getDefaultFrontendLabel(); ?></span></label>
<div class="control">
<select class="option-select color" name="<?php echo $block->getRealAttributeCode($attribute); ?>" id="select-<?php echo $attribute->getAttributeCode(); ?>">
<?php foreach($block->getOptions($attribute) as $key => $value) : ?>
<option value="<?php echo $key; ?>"><?php echo $value; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
So how can I retreive "getDefaultFrontendLabel" from an other store??
解决方案
i have checked your requirement. You should use like below.
Use getStoreLabel() ,instead of getFrontendLabel() or getDefaultFrontendLabel()
Please use like above and let me know if you have any query.