Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/VirtoCommerce.CatalogModule2.Web/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Initialize(IServiceCollection serviceCollection)
serviceCollection.AddTransient<ICategoryService, CategoryService2>();
serviceCollection.AddTransient<ICategoryIndexedSearchService, CategoryIndexedSearchService>();

serviceCollection.AddTransient<IItemService, ItemService2>();
serviceCollection.AddTransient<IProductService, ProductService2>();
serviceCollection.AddTransient<IProductIndexedSearchService, ProductIndexedSearchService2>();
serviceCollection.AddTransient<IAssociationService, AssociationService2>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace VirtoCommerce.CatalogModule2.Data.Search.Indexing
{
public class ProductDocumentBuilder2 : ProductDocumentBuilder
{
public ProductDocumentBuilder2(ISettingsManager settingsManager, IPropertySearchService propertySearchService, IItemService itemService, IProductSearchService productsSearchService)
: base(settingsManager, propertySearchService, itemService, productsSearchService)
public ProductDocumentBuilder2(ISettingsManager settingsManager, IPropertySearchService propertySearchService, IProductService productService, IProductSearchService productsSearchService)
: base(settingsManager, propertySearchService, productService, productsSearchService)
{
}
protected override IndexDocument CreateDocument(CatalogProduct product)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ namespace VirtoCommerce.CatalogModule2.Data.Search.Indexing
{
public class ProductIndexedSearchService2 : ProductIndexedSearchService
{
public ProductIndexedSearchService2(ISearchRequestBuilderRegistrar searchRequestBuilderRegistrar, ISearchProvider searchProvider, ISettingsManager settingsManager, IItemService itemService, IBlobUrlResolver blobUrlResolver, IAggregationConverter aggregationConverter) : base(
public ProductIndexedSearchService2(ISearchRequestBuilderRegistrar searchRequestBuilderRegistrar, ISearchProvider searchProvider, ISettingsManager settingsManager, IProductService productService, IBlobUrlResolver blobUrlResolver, IAggregationConverter aggregationConverter) : base(
searchRequestBuilderRegistrar,
searchProvider,
settingsManager,
itemService,
productService,
blobUrlResolver,
aggregationConverter
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace VirtoCommerce.CatalogModule2.Data.Search
{
public class ListEntrySearchService2 : ListEntrySearchService
{
public ListEntrySearchService2(Func<ICatalogRepository> catalogRepositoryFactory, IItemService itemService, ICategoryService categoryService) : base(catalogRepositoryFactory, itemService, categoryService)
public ListEntrySearchService2(Func<ICatalogRepository> catalogRepositoryFactory, IProductService productService, ICategoryService categoryService) : base(catalogRepositoryFactory, productService, categoryService)
{
}
protected override IQueryable<CategoryEntity> BuildQuery(IQueryable<CategoryEntity> query, CatalogListEntrySearchCriteria criteria)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ProductSearchService2 : ProductSearchService
public ProductSearchService2(
Func<ICatalogRepository> repositoryFactory,
IPlatformMemoryCache platformMemoryCache,
IItemService crudService,
IProductService crudService,
IOptions<CrudOptions> crudOptions)
: base(repositoryFactory, platformMemoryCache, crudService, crudOptions)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace VirtoCommerce.CatalogModule2.Web.Services
public class CatalogSeoDuplicatesDetector2 : CatalogSeoDuplicatesDetector
{
public CatalogSeoDuplicatesDetector2(
IItemService productService,
IProductService productService,
ICategoryService categoryService,
IStoreService storeService,
Func<ICatalogRepository> repositoryFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace VirtoCommerce.CatalogModule2.Data.Services
{
public class ProductMover2 : ProductMover
{
public ProductMover2(IItemService itemService) : base(itemService)
public ProductMover2(IProductService productService) : base(productService)
{
}
public override Task ConfirmMoveAsync(IEnumerable<CatalogProduct> entities)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using FluentValidation;
using VirtoCommerce.AssetsModule.Core.Assets;
using VirtoCommerce.CatalogModule.Core.Model;
using VirtoCommerce.CatalogModule.Core.Services;
using VirtoCommerce.CatalogModule.Data.Repositories;
using VirtoCommerce.CatalogModule.Data.Services;
using VirtoCommerce.Platform.Core.Caching;
using VirtoCommerce.Platform.Core.Events;
namespace VirtoCommerce.CatalogModule2.Web.Services
{
public class ItemService2 : ItemService
{
public ItemService2(
Func<ICatalogRepository> repositoryFactory,
IPlatformMemoryCache platformMemoryCache,
IEventPublisher eventPublisher,
AbstractValidator<IHasProperties> hasPropertyValidator,
ICatalogService catalogService,
ICategoryService categoryService,
IOutlineService outlineService,
IBlobUrlResolver blobUrlResolver,
ISkuGenerator skuGenerator,
AbstractValidator<CatalogProduct> productValidator)
: base(
repositoryFactory,
platformMemoryCache,
eventPublisher,
hasPropertyValidator,
catalogService,
categoryService,
outlineService,
blobUrlResolver,
skuGenerator,
productValidator)
{
}
protected override void ApplyInheritanceRules(IList<CatalogProduct> products)
{
base.ApplyInheritanceRules(products);
}
protected override void ClearCache(IList<CatalogProduct> models)
{
base.ClearCache(models);
}
public override Task DeleteAsync(IList<string> ids, bool softDelete = false)
{
return base.DeleteAsync(ids, softDelete);
}
public override Task<CatalogProduct> GetByIdAsync(string itemId, string responseGroup, string catalogId)
{
return base.GetByIdAsync(itemId, responseGroup, catalogId);
}
public override Task<IList<CatalogProduct>> GetByIdsAsync(IList<string> ids, string responseGroup, string catalogId)
{
return base.GetByIdsAsync(ids, responseGroup, catalogId);
}
protected override Task LoadDependencies(IList<CatalogProduct> products)
{
return base.LoadDependencies(products);
}
public override Task SaveChangesAsync(IList<CatalogProduct> models)
{
return base.SaveChangesAsync(models);
}
protected override void SetProductDependencies(CatalogProduct product, IDictionary<string, Catalog> catalogsByIdDict, IDictionary<string, Category> categoriesByIdDict)
{
base.SetProductDependencies(product, catalogsByIdDict, categoriesByIdDict);
}
protected override Task ValidateProductsAsync(IList<CatalogProduct> products)
{
return base.ValidateProductsAsync(products);
}
}
}
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using FluentValidation;
using VirtoCommerce.AssetsModule.Core.Assets;
using VirtoCommerce.CatalogModule.Core.Model;
using VirtoCommerce.CatalogModule.Core.Services;
using VirtoCommerce.CatalogModule.Data.Repositories;
using VirtoCommerce.CatalogModule.Data.Services;
using VirtoCommerce.Platform.Core.Caching;
using VirtoCommerce.Platform.Core.Events;

namespace VirtoCommerce.CatalogModule2.Web.Services
{
public class ProductService2 : ProductService
{
public ProductService2(
Func<ICatalogRepository> repositoryFactory,
IPlatformMemoryCache platformMemoryCache,
IEventPublisher eventPublisher,
AbstractValidator<IHasProperties> hasPropertyValidator,
ICatalogService catalogService,
ICategoryService categoryService,
IOutlineService outlineService,
IBlobUrlResolver blobUrlResolver,
ISkuGenerator skuGenerator,
AbstractValidator<CatalogProduct> productValidator)
: base(
repositoryFactory,
platformMemoryCache,
eventPublisher,
hasPropertyValidator,
catalogService,
categoryService,
outlineService,
blobUrlResolver,
skuGenerator,
productValidator)
{
}

protected override void ApplyInheritanceRules(IList<CatalogProduct> products)
{
base.ApplyInheritanceRules(products);
}

protected override void ClearCache(IList<CatalogProduct> models)
{
base.ClearCache(models);
}

public override Task DeleteAsync(IList<string> ids, bool softDelete = false)
{
return base.DeleteAsync(ids, softDelete);
}

public override Task<CatalogProduct> GetByIdAsync(string itemId, string responseGroup, string catalogId)
{
return base.GetByIdAsync(itemId, responseGroup, catalogId);
}

public override Task<IList<CatalogProduct>> GetByIdsAsync(IList<string> ids, string responseGroup, string catalogId)
{
return base.GetByIdsAsync(ids, responseGroup, catalogId);
}

protected override Task LoadDependencies(IList<CatalogProduct> products)
{
return base.LoadDependencies(products);
}

public override Task SaveChangesAsync(IList<CatalogProduct> models)
{
return base.SaveChangesAsync(models);
}

protected override void SetProductDependencies(CatalogProduct product, IDictionary<string, Catalog> catalogsByIdDict, IDictionary<string, Category> categoriesByIdDict)
{
base.SetProductDependencies(product, catalogsByIdDict, categoriesByIdDict);
}

protected override Task ValidateProductsAsync(IList<CatalogProduct> products)
{
return base.ValidateProductsAsync(products);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace VirtoCommerce.CatalogModule.BulkActions.Actions.PropertiesUpdate
public class PropertiesUpdateBulkAction : IBulkAction
{
private readonly PropertiesUpdateBulkActionContext _context;
private readonly IItemService _itemService;
private readonly IProductService _productService;
private readonly IBulkPropertyUpdateManager _bulkPropertyUpdateManager;

/// <summary>
Expand All @@ -28,13 +28,25 @@ public class PropertiesUpdateBulkAction : IBulkAction
/// <param name="context">
/// The context.
/// </param>
public PropertiesUpdateBulkAction(PropertiesUpdateBulkActionContext context, IItemService itemService, IBulkPropertyUpdateManager bulkPropertyUpdateManager)
public PropertiesUpdateBulkAction(PropertiesUpdateBulkActionContext context, IProductService productService, IBulkPropertyUpdateManager bulkPropertyUpdateManager)
{
_context = context ?? throw new ArgumentNullException(nameof(context));
_itemService = itemService;
_productService = productService;
_bulkPropertyUpdateManager = bulkPropertyUpdateManager;
}

[Obsolete($"Use the overload that accepts {nameof(IProductService)}")]
public PropertiesUpdateBulkAction(PropertiesUpdateBulkActionContext context, IItemService itemService, IBulkPropertyUpdateManager bulkPropertyUpdateManager)
: this(context, (IProductService)itemService, bulkPropertyUpdateManager)
{
}

[Obsolete($"This constructor is intended to be used by a DI container only")]
public PropertiesUpdateBulkAction(PropertiesUpdateBulkActionContext context, IProductService productService, /* ReSharper disable once UnusedParameter.Local */ IItemService itemService, IBulkPropertyUpdateManager bulkPropertyUpdateManager)
: this(context, productService, bulkPropertyUpdateManager)
{
}

public BulkActionContext Context => _context;

public async Task<BulkActionResult> ExecuteAsync(IEnumerable<IEntity> entities)
Expand All @@ -48,7 +60,7 @@ public async Task<BulkActionResult> ExecuteAsync(IEnumerable<IEntity> entities)

var productQuery = entries.Where(entry => entry.Type.EqualsInvariant(ProductListEntry.TypeName));
var productIds = productQuery.Select(entry => entry.Id).ToList();
var products = await _itemService.GetAsync(productIds, (ItemResponseGroup.ItemInfo | ItemResponseGroup.ItemProperties).ToString());
var products = await _productService.GetAsync(productIds, (ItemResponseGroup.ItemInfo | ItemResponseGroup.ItemProperties).ToString());

return await _bulkPropertyUpdateManager.UpdatePropertiesAsync(products?.ToArray(), _context.Properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class BulkPropertyUpdateManager : IBulkPropertyUpdateManager
private readonly IDataSourceFactory _dataSourceFactory;
private readonly IPropertyUpdateManager _propertyUpdateManager;

private readonly IItemService _itemService;
private readonly IProductService _productService;
private readonly ICategoryService _categoryService;
private readonly ICatalogService _catalogService;

Expand All @@ -27,21 +27,33 @@ public class BulkPropertyUpdateManager : IBulkPropertyUpdateManager
/// <param name="dataSourceFactory">
/// The data source factory.
/// </param>
/// <param name="itemService">
/// <param name="productService">
/// The item service.
/// </param>
/// <param name="categoryService"></param>
/// <param name="catalogService"></param>
/// <param name="propertyUpdateManager"></param>
public BulkPropertyUpdateManager(IDataSourceFactory dataSourceFactory, IItemService itemService, ICategoryService categoryService, ICatalogService catalogService, IPropertyUpdateManager propertyUpdateManager)
public BulkPropertyUpdateManager(IDataSourceFactory dataSourceFactory, IProductService productService, ICategoryService categoryService, ICatalogService catalogService, IPropertyUpdateManager propertyUpdateManager)
{
_dataSourceFactory = dataSourceFactory;
_itemService = itemService;
_productService = productService;
_categoryService = categoryService;
_catalogService = catalogService;
_propertyUpdateManager = propertyUpdateManager;
}

[Obsolete($"Use the overload that accepts {nameof(IProductService)}")]
public BulkPropertyUpdateManager(IDataSourceFactory dataSourceFactory, IItemService itemService, ICategoryService categoryService, ICatalogService catalogService, IPropertyUpdateManager propertyUpdateManager)
: this(dataSourceFactory, (IProductService)itemService, categoryService, catalogService, propertyUpdateManager)
{
}

[Obsolete($"This constructor is intended to be used by a DI container only")]
public BulkPropertyUpdateManager(IDataSourceFactory dataSourceFactory, IProductService productService, /* ReSharper disable once UnusedParameter.Local */ IItemService itemService, ICategoryService categoryService, ICatalogService catalogService, IPropertyUpdateManager propertyUpdateManager)
: this(dataSourceFactory, productService, categoryService, catalogService, propertyUpdateManager)
{
}

public async Task<Property[]> GetPropertiesAsync(BulkActionContext context)
{
var result = new List<Property>();
Expand All @@ -52,7 +64,7 @@ public async Task<Property[]> GetPropertiesAsync(BulkActionContext context)
while (await dataSource.FetchAsync())
{
var productIds = dataSource.Items.Select(item => item.Id).ToList();
var products = await _itemService.GetAsync(productIds, (ItemResponseGroup.ItemInfo | ItemResponseGroup.ItemProperties).ToString());
var products = await _productService.GetAsync(productIds, (ItemResponseGroup.ItemInfo | ItemResponseGroup.ItemProperties).ToString());

// using only product inherited properties from categories,
// own product props (only from PropertyValues) are not set via bulk update action
Expand Down Expand Up @@ -88,7 +100,7 @@ public async Task<BulkActionResult> UpdatePropertiesAsync(CatalogProduct[] produ

if (hasChanges)
{
await _itemService.SaveChangesAsync(products);
await _productService.SaveChangesAsync(products);
}

return result;
Expand Down
Loading