Is it possible to use Login and User Profile from another Database instead of nop commerce Database

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

I have currently been using nop commerce v4.0. For our requirement, we have to access login and user details (like billing address, shipping address, email, contact details, etc.) from other database instead of nop commerce database.

Is this possible. Can any one suggest me to proceed further.

Thanks in advance.
6 years ago
take a look at the facebook plugin
it logs in with facebook and register a user in Nop
6 years ago
Hi hezyz,

Thank for the quick response. I have to access two database one is nopcommerce db and another one which we have created. Our database contains the registered user information and their profile details. We want to access these values to nop commerce website. Is it possible..?


Thanks in advance.
6 years ago
you can work with 2 databases with nop (I am)

you need to create a new ObjectContext (copy the nop one, change the names and add your tables)
create a new EfStartUpTask (copy the nop one under different namespace)
create all data objects and maps

then in your project you create a new dependencyRegister class and add the new DB connection
u need to create the setting.json as well, copy the nop setting.json and change the name

this is how it should look like, the last section are the tables u add


using Autofac;
using Autofac.Core;
using Nop.Core;
using Nop.Core.Configuration;
using Nop.Core.Data;
using Nop.Core.Domain.WindAlert;
using Nop.Core.Infrastructure;
using Nop.Core.Infrastructure.DependencyManagement;
using Nop.Data;
using Nop.Data.WindAlert;
using Nop.Services.Media;
using Nop.Services.WindAlert;
using Nop.Web.Factories;

namespace Nop.Web.WindAlert
{
    public class DependencyRegistrar : IDependencyRegistrar
    {
        // <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            //windalert
            builder.RegisterType<SpotService>().As<ISpotService>().InstancePerLifetimeScope();

            #region Data

            ////data layer
            var DataSettingsFilePath = "~/App_Data/newName.json";
            var windalertFilePath =  CommonHelper.MapPath(DataSettingsFilePath);

            //data layer
            var dataSettingsManager = new DataSettingsManager();
            var dataProviderSettings = dataSettingsManager.LoadSettings(windalertFilePath, true);

            if (dataProviderSettings != null && dataProviderSettings.IsValid())
            {
                //register named context
                //register named context
                builder.Register<IDbContext>(c => new WindAlertObjectContext(dataProviderSettings.DataConnectionString))
                    .Named<IDbContext>("nop_object_context_windalert")
                    .InstancePerLifetimeScope();

                builder.Register(c => new WindAlertObjectContext(dataProviderSettings.DataConnectionString))
                    .InstancePerLifetimeScope();
            }
            else
            {
                //register named context
                builder.Register<IDbContext>(c => new WindAlertObjectContext(c.Resolve<DataSettings>().DataConnectionString))
                   .Named<IDbContext>("nop_object_context_windalert")
                   .InstancePerLifetimeScope();

                builder.Register(c => new WindAlertObjectContext(c.Resolve<DataSettings>().DataConnectionString))
                    .InstancePerLifetimeScope();
            }

            //override required repository with our custom context
            builder.RegisterType<EfRepository<WindData>>()
                .As<IRepository<WindData>>()
                .WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_windalert"))
                .InstancePerLifetimeScope();
            builder.RegisterType<EfRepository<WaveData>>()
                .As<IRepository<WaveData>>()
                .WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_windalert"))
                .InstancePerLifetimeScope();
            builder.RegisterType<EfRepository<ForecastData>>()
               .As<IRepository<ForecastData>>()
               .WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_windalert"))
               .InstancePerLifetimeScope();
            builder.RegisterType<EfRepository<MagicData>>()
               .As<IRepository<MagicData>>()
               .WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_windalert"))
               .InstancePerLifetimeScope();
        #endregion
        }

        public int Order
        {
            get { return 1; }
        }
    }
}

6 years ago
Hi Hezyz,

Thanks for the reply. We have using nopcommerce V4.0, In this version DependencyRegistrar are placed in the following.
1. Nop.Services.Tests\DependencyRegistrar.cs (There we don't need to change it)
2. Nop.Web.Framework\Infrastructure\DependencyRegistrar.cs
3. Nop.Web.Framework\Infrastructure\DependencyRegistrarExtensions.cs
4. Nop.Plugin.Pickup.PickupInStore\Infrastructure\DependencyRegistrar.cs
5. Nop.Plugin.Shipping.FixedOrByWeight\Infrastructure\DependencyRegistrar.cs
6. Nop.Plugin.Tax.FixedOrByCountryStateZip\Infrastructure\DependencyRegistrar.cs
7. Nop.Plugin.Payments.Worldpay\Infrastructure\DependencyRegistrar.cs
8. Nop.Plugin.Payments.Square\Infrastructure\DependencyRegistrar.cs

Kindly suggest us exactly where should we register our dependency.

Thanks in advance.
6 years ago
sengottuvelum wrote:
Hi,

I have currently been using nop commerce v4.0. For our requirement, we have to access login and user details (like billing address, shipping address, email, contact details, etc.) from other database instead of nop commerce database.

Is this possible. Can any one suggest me to proceed further.

Thanks in advance.


Hi,

you can do it by creating sql link server between two database and fetch all your required information from your source db to nopcommerce db (in nopcommerce tables).

As far as data modification concern from your source db, make sql job to update your data from source db to nop db. so you will have updated data in nopdb.

For this, I don't think there might be a change in nopCommerce default code.

Kindly request you to think in this way.

Thank You.
6 years ago
Hi SuperNopCommerce,

Thanks for the reply,

So as per your concern, we can't use the sign in by using another website. By only have to can use nopcommerce database alone..!
Is there any possibility have to use single sign on to another site, After successful login we redirect to nopcommerce site (Without using a nopcommerce database login and user details).
6 years ago
sengottuvelum wrote:
Hi Hezyz,

Thanks for the reply. We have using nopcommerce V4.0, In this version DependencyRegistrar are placed in the following.
1. Nop.Services.Tests\DependencyRegistrar.cs (There we don't need to change it)
2. Nop.Web.Framework\Infrastructure\DependencyRegistrar.cs
3. Nop.Web.Framework\Infrastructure\DependencyRegistrarExtensions.cs
4. Nop.Plugin.Pickup.PickupInStore\Infrastructure\DependencyRegistrar.cs
5. Nop.Plugin.Shipping.FixedOrByWeight\Infrastructure\DependencyRegistrar.cs
6. Nop.Plugin.Tax.FixedOrByCountryStateZip\Infrastructure\DependencyRegistrar.cs
7. Nop.Plugin.Payments.Worldpay\Infrastructure\DependencyRegistrar.cs
8. Nop.Plugin.Payments.Square\Infrastructure\DependencyRegistrar.cs

Kindly suggest us exactly where should we register our dependency.

Thanks in advance.


it up to u u can add it to the web project or create a plugin for it
it should be under new namespace

I work with in the Nop projects (i have a lot of costimazed code), I put all my classes in a new folder (name it with a Z at the start so it will be the last folder always ) for each of the projects. Use only partial classes, so I never change Nop original files, this way it is very easy to upgrade for new version.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.