Adding new Setting to CustomerSettings in Setting Table

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi all,

I want to add client code value to settings table in table and use that using _catalogSettings objects. But when I added that to database and also I added that to catalogsettings model but still the value in database is not getting returned. Can someone help me fix it.
6 years ago
show us the code you are using - will help.
6 years ago
I just added inventory.clientcode and set the value to "Test" in setting table of database. I wanted to use this particular value in my code. So how can I get to the settings table and grab that row value was my question.
6 years ago
use ISettingService


var setting = _settingService.GetSetting("YourSettingName");


Check this out: http://docs.nopcommerce.com/display/en/Settings+API
6 years ago
Hello Sean,

Thanks for the reply. I have tried that but still it returns null. I have tried to access other settings value and they seem to return a value. So the problem is with the setting that I added in database.

Do you think I am missing adding the ClientCode variable somewhere ?

I have added that to catalogsettings.cs in nop.core.domain as public string ClientCode { get; set; }
6 years ago
If you've added the property to the CatalogSettings domain class, then the setting service will prefix the property name with CatalogSettings when it reads it.

Rename the setting name (in the settings table) to catalogsettings.clientcode

If you query the settings table for anything that starts with catalogsettings, you notice how they match the property names of the CatalogSettings domain class.
5 years ago
For nopCommerce 4.10 this is what I did.

Go to nopCommerce Admin center and go to add settings


Configuration -> Settings -> All Settings

Click "Add new record"
Created a custom setting and values.
CustomFooterLinks.BillingSite = "https://billingsite.com"

Edit the view you want to use the setting on, like the footer view.

filename: \Presentation\Nop.Web\Themes\Burkhart\Views\Shared\Components\Footer\Default.cshtml

NOTE: Need to add @using Nop.Core.Infrastructure


@model FooterModel
@using Nop.Core
@using Nop.Core.Domain.Tax
@using Nop.Core.Infrastructure
@inject IWorkContext workContext;
@{
    // see: https://wittylog.com/how-to-access-custom-settings-in-nopcommerce
    //      https://www.nopcommerce.com/boards/t/47772/adding-new-setting-to-customersettings-in-setting-table.aspx
    var settingService = EngineContext.Current.Resolve<Nop.Services.Configuration.ISettingService>();

    var billingLink = settingService.GetSetting("CustomFooterLinks.BillingSite");

}
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.