How to get a localized value?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
How to get a localized value? This function returns knowledge only in Russian.


string catValue = "";
          try
                {
                    catId = Convert.ToInt32(doc.XPathSelectElement("//ProductAttribute[@ID='1']/ProductAttributeValue/Value").Value);
                    catValue = $"{_productAttributeService.GetProductAttributeValueById(catId).Name}";                    
                }
                catch { }
4 years ago
Your question is not clear to me. Can you please write in details here?
4 years ago
mhsjaber wrote:
Your question is not clear to me. Can you please write in details here?


the ProductAttributeValue table stores attribute values in Russian. How can I use this function
_productAttributeService.GetProductAttributeValueById

from the box to return a localized value?
4 years ago
Try this.

var productAttributeValue = _productAttributeService.GetProductAttributeValueById(attributeValueId);

var name = _localizationService.GetLocalized(productAttributeValue, x => x.Name, lang.Id, false, false);
4 years ago
mhsjaber wrote:
Try this.

var productAttributeValue = _productAttributeService.GetProductAttributeValueById(attributeValueId);

var name = _localizationService.GetLocalized(productAttributeValue, x => x.Name, lang.Id, false, false);


Error  CS1501  No overload for method 'GetLocalized' takes 5 arguments
4 years ago
What is your nopCommerce version?
4 years ago
mhsjaber wrote:
What is your nopCommerce version?


3.9
4 years ago
Ok, then try this.

var name = productAttributeValue.GetLocalized(x => x.Name, lang.Id, false, false);
4 years ago
mhsjaber wrote:
Ok, then try this.

var name = productAttributeValue.GetLocalized(x => x.Name, lang.Id, false, false);


The name 'lang' does not exist in the current context
The name 'productAttributeValue' does not exist in the current context
4 years ago
Try this
var productAttributeValue = _productAttributeService.GetProductAttributeValueById(attributeValueId);

var name = productAttributeValue.GetLocalized(x => x.Name, _workContext.WorkingLanguage.Id, false, false);
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.