Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Update migration process - update store

KrzysztofPajak79adb02cc4c7
diff --git a/src/Business/Grand.Business.System/Services/Migrations/1.1/MigrationUpdateStore.cs b/src/Business/Grand.Business.System/Services/Migrations/1.1/MigrationUpdateStore.cs
index 5b015e8f2..864d04a8d 100644
--- a/src/Business/Grand.Business.System/Services/Migrations/1.1/MigrationUpdateStore.cs
+++ b/src/Business/Grand.Business.System/Services/Migrations/1.1/MigrationUpdateStore.cs
@@ -5,6 +5,7 @@ using Grand.Infrastructure.Migrations;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System;
+using System.Linq;
namespace Grand.Business.System.Services.Migrations._1._1
{
@@ -29,16 +30,18 @@ namespace Grand.Business.System.Services.Migrations._1._1
{
foreach (var store in repository.Table)
{
- var host = new HostString(store.Url);
- var httpscheme = store.SslEnabled ? "https" : "http";
- var domain = new DomainHost() {
- HostName = host.Host,
- Url = $"{httpscheme}://{host}",
- Primary = true
- };
- store.Domains.Add(domain);
-
- repository.Update(store);
+ if (!store.Domains.Any())
+ {
+ var storeUri = new Uri(store.Url);
+ var httpscheme = store.SslEnabled ? "https" : "http";
+ var domain = new DomainHost() {
+ HostName = storeUri.Authority,
+ Url = $"{httpscheme}://{storeUri.Authority}",
+ Primary = true
+ };
+ store.Domains.Add(domain);
+ repository.Update(store);
+ }
}
}
catch (Exception ex)