how to get the value of the setting I specified in the table setting in the view?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 năm cách đây
how to get the value of the setting I specified in the table setting in the view?

thanks
5 năm cách đây
Hi,

In nop 4.1 just use the following code in the view:

@inject Nop.Services.Configuration.ISettingService settingService
@{
    var value = settingService.GetSettingByKey<YOUR_SETTING_TYPE>(YOUR_KEY);
}


Regards
5 năm cách đây
resanehlab wrote:
Hi,

In nop 4.1 just use the following code in the view:

@inject Nop.Services.Configuration.ISettingService settingService
@{
    var value = settingService.GetSettingByKey<YOUR_SETTING_TYPE>(YOUR_KEY);
}


Regards


ver. 3.9
5 năm cách đây
@using Nop.Core.Infrastructure
@using Nop.Services.Configuration
@{
    var value = EngineContext.Current.Resolve<ISettingService>().GetSettingByKey<YOUR_SETTING_TYPE>(YOUR_KEY);
}
2 năm cách đây
What do you mean by "SETTING_TYPE"?
2 năm cách đây
I used `GetSetting()` instead:

var value = EngineContext.Current.Resolve<ISettingService>()
.GetSetting("YOUR_KEY").Value;
2 năm cách đây
You have to use GetSettingByKey method instead of GetSetting and pass your key as parameter

if it nopCommerce 4.40, then use GetSettingByKeyAsync method
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.