Skip to content

Commit

Permalink
Merge branch 'dev' into feat/VCST-2303
Browse files Browse the repository at this point in the history
  • Loading branch information
ksavosteev authored Dec 4, 2024
2 parents bbeca03 + d13f091 commit b0153b8
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<!-- These properties will be shared for all projects -->
<PropertyGroup>
<VersionPrefix>3.817.0</VersionPrefix>
<VersionPrefix>3.818.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' != '' AND '$(BuildNumber)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.Xapi.Core" Version="3.809.0" />
<PackageReference Include="VirtoCommerce.XCatalog.Core" Version="3.817.0" />
<PackageReference Include="VirtoCommerce.XCatalog.Core" Version="3.818.0" />
<PackageReference Include="VirtoCommerce.CartModule.Core" Version="3.820.0" />
<PackageReference Include="VirtoCommerce.PaymentModule.Core" Version="3.804.0" />
<PackageReference Include="VirtoCommerce.ShippingModule.Core" Version="3.802.0" />
Expand Down
17 changes: 15 additions & 2 deletions src/VirtoCommerce.XCart.Data/Commands/AddCartItemCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using VirtoCommerce.CatalogModule.Core.Model.Search;
using VirtoCommerce.CatalogModule.Core.Search;
using VirtoCommerce.Platform.Core.Common;
using VirtoCommerce.XCart.Core;
using VirtoCommerce.XCart.Core.Commands;
using VirtoCommerce.XCart.Core.Commands.BaseCommands;
Expand All @@ -14,15 +17,19 @@ public class AddCartItemCommandHandler : CartCommandHandler<AddCartItemCommand>
{
private readonly ICartProductService _cartProductService;
private readonly IMediator _mediator;
private readonly IProductConfigurationSearchService _productConfigurationSearchService;

public AddCartItemCommandHandler(
ICartAggregateRepository cartAggregateRepository,
ICartProductService cartProductService,
IMediator mediator)
IMediator mediator,
IProductConfigurationSearchService productConfigurationSearchService
)
: base(cartAggregateRepository)
{
_cartProductService = cartProductService;
_mediator = mediator;
_productConfigurationSearchService = productConfigurationSearchService;
}

public override async Task<CartAggregate> Handle(AddCartItemCommand request, CancellationToken cancellationToken)
Expand All @@ -38,7 +45,13 @@ public override async Task<CartAggregate> Handle(AddCartItemCommand request, Can
CartProduct = product,
};

if (product?.Product?.IsConfigurable == true)
var configurations = await _productConfigurationSearchService.SearchNoCloneAsync(new ProductConfigurationSearchCriteria
{
ProductId = request.ProductId
});
var configuration = configurations.Results.FirstOrDefault();

if (configuration?.IsActive == true)
{
var createConfigurableProductCommand = new CreateConfiguredLineItemCommand
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using VirtoCommerce.CatalogModule.Core.Services;
using VirtoCommerce.CatalogModule.Core.Model.Configuration;
using VirtoCommerce.CatalogModule.Core.Model.Search;
using VirtoCommerce.CatalogModule.Core.Search;
using VirtoCommerce.Platform.Core.Common;
using VirtoCommerce.Xapi.Core.Infrastructure;
using VirtoCommerce.XCart.Core;
using VirtoCommerce.XCart.Core.Models;
Expand All @@ -12,23 +15,30 @@ namespace VirtoCommerce.XCatalog.Data.Queries;

public class GetProductConfigurationQueryHandler : IQueryHandler<GetProductConfigurationQuery, ProductConfigurationQueryResponse>
{
private readonly IConfigurableProductService _configurableProductService;
private readonly IProductConfigurationSearchService _productConfigurationSearchService;
private readonly IConfiguredLineItemContainerService _configuredLineItemContainerService;
private readonly ICartProductsLoaderService _cartProductService;

public GetProductConfigurationQueryHandler(
IConfigurableProductService configurableProductService,
IProductConfigurationSearchService productConfigurationSearchService,
IConfiguredLineItemContainerService configuredLineItemContainerService,
ICartProductsLoaderService cartProductService)
{
_configurableProductService = configurableProductService;
_productConfigurationSearchService = productConfigurationSearchService;
_configuredLineItemContainerService = configuredLineItemContainerService;
_cartProductService = cartProductService;
}

public async Task<ProductConfigurationQueryResponse> Handle(GetProductConfigurationQuery request, CancellationToken cancellationToken)
{
var configuration = await _configurableProductService.GetProductConfigurationAsync(request.ConfigurableProductId);
var result = new ProductConfigurationQueryResponse();

var configuration = await GetConfiguration(request);

if (configuration == null)
{
return result;
}

var container = await _configuredLineItemContainerService.CreateContainerAsync(request);

Expand All @@ -40,7 +50,6 @@ public async Task<ProductConfigurationQueryResponse> Handle(GetProductConfigurat

var productByIds = cartProducts.ToDictionary(x => x.Product.Id, x => x);

var result = new ProductConfigurationQueryResponse();
foreach (var section in configuration.Sections)
{
var configurationSection = new ExpProductConfigurationSection
Expand All @@ -49,7 +58,6 @@ public async Task<ProductConfigurationQueryResponse> Handle(GetProductConfigurat
Name = section.Name,
IsRequired = section.IsRequired,
Description = section.Description,
Type = section.Type,
};
result.ConfigurationSections.Add(configurationSection);

Expand All @@ -76,4 +84,13 @@ public async Task<ProductConfigurationQueryResponse> Handle(GetProductConfigurat

return result;
}

private async Task<ProductConfiguration> GetConfiguration(GetProductConfigurationQuery request)
{
var criteria = AbstractTypeFactory<ProductConfigurationSearchCriteria>.TryCreateInstance();
criteria.ProductId = request.ConfigurableProductId;

var configurationsResult = await _productConfigurationSearchService.SearchNoCloneAsync(criteria);
return configurationsResult.Results.FirstOrDefault();
}
}
4 changes: 2 additions & 2 deletions src/VirtoCommerce.XCart.Web/module.manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<module>
<id>VirtoCommerce.XCart</id>
<version>3.817.0</version>
<version>3.818.0</version>
<version-tag></version-tag>

<platformVersion>3.867.0</platformVersion>
Expand All @@ -13,7 +13,7 @@
<dependency id="VirtoCommerce.Pricing" version="3.809.0" />
<dependency id="VirtoCommerce.Shipping" version="3.802.0" />
<dependency id="VirtoCommerce.Xapi" version="3.809.0" />
<dependency id="VirtoCommerce.XCatalog" version="3.817.0" />
<dependency id="VirtoCommerce.XCatalog" version="3.818.0" />
</dependencies>

<title>Cart Experience API</title>
Expand Down

0 comments on commit b0153b8

Please sign in to comment.