Add settings for new plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
My plugin is similar to NEWS module. How can I save to these settings? Do I have to add some (setting) rows to DB manually?


public class ContentSettings : ISettings
    {
        /// <summary>
        /// Gets or sets a value indicating whether Content are enabled
        /// </summary>
        public bool Enabled { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether not registered user can leave comments
        /// </summary>
        public bool AllowNotRegisteredUsersToLeaveComments { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to notify about new Content comments
        /// </summary>
        public bool NotifyAboutNewContentComments { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to show Content on the main page
        /// </summary>
        public bool ShowContentOnMainPage { get; set; }

        /// <summary>
        /// Gets or sets a value indicating Content count displayed on the main page
        /// </summary>
        public int MainPageContentCount { get; set; }

        /// <summary>
        /// Gets or sets the page size for Content archive
        /// </summary>
        public int ContentArchivePageSize { get; set; }

        /// <summary>
        /// Enable the Content RSS feed link in customers browser address bar
        /// </summary>
        public bool ShowHeaderRssUrl { get; set; }
    }
11 years ago
You need to inject the SettingService into your Controller and other classes that need access to settings.

Look at an existing plugin like Shipping.ByWeight.

...\src\Plugins\Nop.Plugin.Shipping.ByWeight\Controllers\ShippingByWeightController.cs

            _shippingByWeightSettings.LimitMethodsToCreated = model.LimitMethodsToCreated;
            _shippingByWeightSettings.CalculatePerWeightUnit = model.CalculatePerWeightUnit;
            _settingService.SaveSetting(_shippingByWeightSettings);
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.