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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Minor changes - import manager
KrzysztofPajak7347748eea38
diff --git a/src/Business/Grand.Business.System/Interfaces/ExportImport/IImportManager.cs b/src/Business/Grand.Business.System/Interfaces/ExportImport/IImportManager.csindex 6d2c90518..9afca1bce 100644--- a/src/Business/Grand.Business.System/Interfaces/ExportImport/IImportManager.cs+++ b/src/Business/Grand.Business.System/Interfaces/ExportImport/IImportManager.cs@@ -18,8 +18,9 @@ namespace Grand.Business.System.Interfaces.ExportImport/// Import newsletter subscribers from TXT file/// </summary>/// <param name="stream">Stream</param>+ /// <param name="currentStoreId">Current store ident</param>/// <returns>Number of imported subscribers</returns>- Task<int> ImportNewsletterSubscribersFromTxt(Stream stream);+ Task<int> ImportNewsletterSubscribersFromTxt(Stream stream, string currentStoreId);/// <summary>/// Import country states from XLSX filediff --git a/src/Business/Grand.Business.System/Services/ExportImport/ImportManager.cs b/src/Business/Grand.Business.System/Services/ExportImport/ImportManager.csindex 9a6cde657..5b7516dc2 100644--- a/src/Business/Grand.Business.System/Services/ExportImport/ImportManager.cs+++ b/src/Business/Grand.Business.System/Services/ExportImport/ImportManager.cs@@ -1,3 +1,4 @@+using Grand.Business.Catalog.Interfaces.Brands;using Grand.Business.Catalog.Interfaces.Categories;using Grand.Business.Catalog.Interfaces.Collections;using Grand.Business.Catalog.Interfaces.Products;@@ -7,18 +8,19 @@ using Grand.Business.Common.Extensions;using Grand.Business.Common.Interfaces.Directory;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Seo;+using Grand.Business.Common.Interfaces.Stores;using Grand.Business.Customers.Interfaces;using Grand.Business.Marketing.Interfaces.Newsletters;using Grand.Business.Storage.Interfaces;using Grand.Business.System.Interfaces.ExportImport;using Grand.Business.System.Utilities;-using Grand.Infrastructure;using Grand.Domain.Catalog;using Grand.Domain.Directory;using Grand.Domain.Media;using Grand.Domain.Messages;using Grand.Domain.Seo;using Grand.Domain.Shipping;+using Grand.Domain.Stores;using Grand.Domain.Tax;using Grand.SharedKernel;using Microsoft.AspNetCore.StaticFiles;@@ -28,9 +30,6 @@ using System.Collections.Generic;using System.IO;using System.Linq;using System.Threading.Tasks;-using Grand.Business.Catalog.Interfaces.Brands;-using Grand.Domain.Stores;-using Grand.Business.Common.Interfaces.Stores;namespace Grand.Business.System.Services.ExportImport{@@ -49,7 +48,6 @@ namespace Grand.Business.System.Services.ExportImportprivate readonly IProductCollectionService _productCollectionService;private readonly IPictureService _pictureService;private readonly ISlugService _slugService;- private readonly IWorkContext _workContext;private readonly INewsLetterSubscriptionService _newsLetterSubscriptionService;private readonly INewsletterCategoryService _newsletterCategoryService;private readonly ICountryService _countryService;@@ -79,7 +77,6 @@ namespace Grand.Business.System.Services.ExportImportIProductCollectionService productCollectionService,IPictureService pictureService,ISlugService slugService,- IWorkContext workContext,INewsLetterSubscriptionService newsLetterSubscriptionService,INewsletterCategoryService newsletterCategoryService,ICountryService countryService,@@ -105,7 +102,6 @@ namespace Grand.Business.System.Services.ExportImport_productCollectionService = productCollectionService;_pictureService = pictureService;_slugService = slugService;- _workContext = workContext;_newsLetterSubscriptionService = newsLetterSubscriptionService;_newsletterCategoryService = newsletterCategoryService;_countryService = countryService;@@ -336,7 +332,7 @@ namespace Grand.Business.System.Services.ExportImportproduct.IsTele = property.BooleanValue;break;case "manageinventorymethodid":- product.ManageInventoryMethodId =(ManageInventoryMethod)property.IntValue;+ product.ManageInventoryMethodId = (ManageInventoryMethod)property.IntValue;break;case "usemultiplewarehouses":product.UseMultipleWarehouses = property.BooleanValue;@@ -482,8 +478,7 @@ namespace Grand.Business.System.Services.ExportImportvar category = await _categoryService.GetCategoryById(id);if (category != null){- var productCategory = new ProductCategory- {+ var productCategory = new ProductCategory {CategoryId = category.Id,IsFeaturedProduct = false,DisplayOrder = 1@@ -504,8 +499,7 @@ namespace Grand.Business.System.Services.ExportImportvar collection = await _collectionService.GetCollectionById(id);if (collection != null){- var productCollection = new ProductCollection- {+ var productCollection = new ProductCollection {CollectionId = collection.Id,IsFeaturedProduct = false,DisplayOrder = 1@@ -552,10 +546,9 @@ namespace Grand.Business.System.Services.ExportImportif (!pictureAlreadyExists){- var picture = await _pictureService.InsertPicture(newPictureBinary, mimeType, _pictureService.GetPictureSeName(product.Name),"","", false,+ var picture = await _pictureService.InsertPicture(newPictureBinary, mimeType, _pictureService.GetPictureSeName(product.Name), "", "", false,Domain.Common.Reference.Product, product.Id);- var productPicture = new ProductPicture- {+ var productPicture = new ProductPicture {PictureId = picture.Id,DisplayOrder = 1,};@@ -569,8 +562,7 @@ namespace Grand.Business.System.Services.ExportImport{var mimeType = GetMimeTypeFromFilePath(picturePath);var picture = await _pictureService.InsertPicture(fileBinary, mimeType, _pictureService.GetPictureSeName(product.Name), "", "", false, Domain.Common.Reference.Product, product.Id);- var productPicture = new ProductPicture- {+ var productPicture = new ProductPicture {PictureId = picture.Id,DisplayOrder = 1,};@@ -781,8 +773,7 @@ namespace Grand.Business.System.Services.ExportImport}else{- subscription = new NewsLetterSubscription- {+ subscription = new NewsLetterSubscription {Active = isActive,CreatedOnUtc = DateTime.UtcNow,Email = email,@@ -940,7 +931,7 @@ namespace Grand.Business.System.Services.ExportImportcontinue;if (isNew)- {+ {await _productService.InsertProduct(product);}else@@ -982,8 +973,9 @@ namespace Grand.Business.System.Services.ExportImport/// Import newsletter subscribers from TXT file/// </summary>/// <param name="stream">Stream</param>+ /// <param name="currentStoreId">Current store ident</param>/// <returns>Number of imported subscribers</returns>- public virtual async Task<int> ImportNewsletterSubscribersFromTxt(Stream stream)+ public virtual async Task<int> ImportNewsletterSubscribersFromTxt(Stream stream, string currentStoreId){int count = 0;using (var reader = new StreamReader(stream))@@ -999,7 +991,7 @@ namespace Grand.Business.System.Services.ExportImportbool isActive = true;var categories = new List<string>();bool iscategories = false;- string storeId = _workContext.CurrentStore.Id;+ string storeId = currentStoreId;//parseif (tmp.Length == 1){diff --git a/src/Web/Grand.Web.Admin/Controllers/NewsLetterSubscriptionController.cs b/src/Web/Grand.Web.Admin/Controllers/NewsLetterSubscriptionController.csindex 5f1435e70..14d5acd24 100644--- a/src/Web/Grand.Web.Admin/Controllers/NewsLetterSubscriptionController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/NewsLetterSubscriptionController.cs@@ -210,7 +210,7 @@ namespace Grand.Web.Admin.Controllers{if (importcsvfile != null && importcsvfile.Length > 0){- int count = await _importManager.ImportNewsletterSubscribersFromTxt(importcsvfile.OpenReadStream());+ int count = await _importManager.ImportNewsletterSubscribersFromTxt(importcsvfile.OpenReadStream(), _workContext.CurrentStore.Id);Success(String.Format(_translationService.GetResource("admin.marketing.NewsLetterSubscriptions.ImportEmailsSuccess"), count));return RedirectToAction("List");}