Store Settings Store Url

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 年 前
Hi,

In nopCommerce 3, how do I pull the Store Url? It is no longer located in store settings. Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Nop.Core.Configuration;
using Nop.Core.Domain;
using Nop.Core.Domain.Tasks;
using Nop.Core.Infrastructure;
using Nop.Plugin.Accounting.QuickBooks;
using Nop.Services.Logging;
using Nop.Services.Tasks;

namespace Nop.Plugin.Accounting.QuickBooks
{
    /// <summary>
    /// Represents a task for keeping the site alive
    /// </summary>
    public partial class QBTask : ITask
    {
        StoreInformationSettings _storeInformationSettings;
        QuickBooksSettings _quickBooksSettings;

        public QBTask(StoreInformationSettings storeInformationSettings, QuickBooksSettings quickBooksSettings)
        {
            _storeInformationSettings = storeInformationSettings;
            _quickBooksSettings = quickBooksSettings;
        }

        public void Execute()
        {
            string url = String.Format("www.mysite.com?Email={0}&QBUrl={1}", _quickBooksSettings.QuickBooksOnlineEmail, NEED STORE URL);
            string result = ServiceExists(url);
            ILogger logger = EngineContext.Current.Resolve<ILogger>();
            logger.InsertLog(Core.Domain.Logging.LogLevel.Information, result, result, null);
        }

        string ServiceExists(string url)
        {
            try
            {

                // try accessing the web service directly via it's URL
                HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
                request.Timeout = 120000;

                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    return "Sync successful!";
                }
            }
            catch (WebException ex)
            {
                return "Error syncing to QBO " + ex.ToString();
            }
        }

    }
}
11 年 前
nopCommerce v3.0 comes with multi-store feature. Hence, store parameters have moved from system settings to a separate "Store" entity that can be dealt with like any other entity in the system, such as categories and products.
11 年 前
See \Libraries\Nop.Services\Common\KeepAliveTask.cs file to get an idea
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.