Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
What is the preferred method for adding custom settings to our store? I see there is a table called ac_StoreSettings that seems to somehow be mapped to properties in the StoreSettingsManager. Is there a way to add our own properties to this and map them to the table? Otherwise, I'm thinking of using the ac_CustomFields table.
|
|
|
|
Rank: Advanced Member
Groups: HelpDesk, Developers Joined: 11/9/2018(UTC) Posts: 564
Thanks: 122 times Was thanked: 26 time(s) in 25 post(s)
|
You can modify the StoreSettingsManager class if you want to do things exactly the way Able does. They have some efficiencies built into the instance that might benefit a high traffic site. I take a shorter route that doesn't necessary possess the same efficiencies but is also much easier/quicker to implement. Here's an example static class I make and throw in the /Code/ folder: Code:
using AbleMods.Signifyd;
using CommerceBuilder.Common;
using CommerceBuilder.Stores;
using CommerceBuilder.Utility;
namespace AbleMods
{
public static class CustomSettings
{
#region Signifyd
public static SignifydOperatingMode SignifydOperatingMode
{
get { return (SignifydOperatingMode) CustomSettings.SignifydOperatingModeId; }
set { CustomSettings.SignifydOperatingModeId = (int) value; }
}
public static int SignifydOperatingModeId
{
get { return AlwaysConvert.ToInt(GetValue("SignifydOperatingModeId")); }
set { SetValue("SignifydOperatingModeId", value.ToString()); }
}
public static string SignifydLiveApiKey
{
get { return GetValue("SignifydLiveApiKey"); }
set { SetValue("SignifydLiveApiKey", value); }
}
public static string SignifydTestApiKey
{
get { return GetValue("SignifydTestApiKey"); }
set { SetValue("SignifydTestApiKey", value); }
}
public static string SignifydApiUrl
{
get { return GetValue("SignifydApiUrl"); }
set { SetValue("SignifydApiUrl", value); }
}
public static bool SignifydTestMode
{
get { return AlwaysConvert.ToBool(GetValue("SignifydTestMode"), true); }
set { SetValue("SignifydTestMode", value.ToString()); }
}
public static bool SignifydDebugLogging
{
get { return AlwaysConvert.ToBool(GetValue("SignifydDebugLogging"), false); }
set { SetValue("SignifydDebugLogging", value.ToString()); }
}
#endregion
#region helper methods
private static string GetValue(string key)
{
StoreSettingsManager settings = AbleContext.Current.Store.Settings;
return settings.GetValueByKey(key);
}
private static void SetValue(string key, string value)
{
StoreSettingsManager settings = AbleContext.Current.Store.Settings;
settings.SetValueByKey(key, value);
settings.Save();
}
#endregion
}
}
|
2 users thanked Joe Payne2 for this useful post.
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Joe, that is a great answer and showed exactly what I needed. Thank you very much for your help!
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close