logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
sweeperqb  
#1 Posted : Monday, April 26, 2021 3:25:28 PM(UTC)
sweeperqb

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.

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

Joe Payne2  
#2 Posted : Monday, April 26, 2021 3:27:09 PM(UTC)
Joe Payne2

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
    }
}
thanks 2 users thanked Joe Payne2 for this useful post.
sweeperqb on 4/26/2021(UTC), mazhar on 4/28/2021(UTC)
sweeperqb  
#3 Posted : Monday, April 26, 2021 3:41:28 PM(UTC)
sweeperqb

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!
Users browsing this topic
Guest
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.