I am having an issue with translations for the product categories.
Example controller :
@AuraEnabled
public static List<ProductCategory> getCategoriesTest(){
return [SELECT toLabel(Name), ParentCategoryId From ProductCategory WHERE ParentCategoryId = 'xxx'];
}
This query works perfectly fine in the developer console and I get the Category Name in the proper language.
But when I call the controller from a lightning web component (I checked that the locale and language of the user were correct in the controller with UserInfo.getLocale() and UserInfo.getLanguage()), I always get the Category Name in english.
Am I doing something wrong or is this an issue with Salesforce ?
Thank you ! Julien
ProductCategory
seems like a unique object, it has its own metadata type just for translating. It could be that this isn't supported in an AuraEnabled method (in which case, definitely raise a case with Salesforce). If it's not, you may be able to try SOSL or consider referencing theProductCategoryDataTranslation
metadata to get the translation you need.ProductCategoryDataTranslation