Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/grandnode/grandnode into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
KrzysztofPajak committed May 5, 2020
2 parents 033d0dc + 4ca3cce commit 6cd731c
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 128 deletions.
8 changes: 8 additions & 0 deletions Grand.Services/Installation/CodeFirstInstallationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4608,6 +4608,14 @@ protected virtual async Task InstallMessageTemplates()
IsActive = true,
EmailAccountId = eaGeneral.Id,
},
new MessageTemplate
{
Name = "VendorInformationChange.StoreOwnerNotification",
Subject = "{{Store.Name}}. Vendor {{Vendor.Name}} changed provided information",
Body = "<p><a href=\"{{Store.URL}}\">{{Store.Name}}</a> <br />\r\n<br />\r\n{{Vendor.Name}} changed provided information.</p>",
IsActive = false,
EmailAccountId = eaGeneral.Id,
},
};
await _messageTemplateRepository.InsertAsync(messageTemplates);
}
Expand Down
36 changes: 32 additions & 4 deletions Grand.Web/Features/Handlers/Catalog/GetVendorHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Grand.Core.Domain.Catalog;
using Grand.Core;
using Grand.Core.Caching;
using Grand.Core.Domain.Catalog;
using Grand.Core.Domain.Media;
using Grand.Core.Domain.Vendors;
using Grand.Services.Catalog;
using Grand.Services.Localization;
using Grand.Services.Media;
using Grand.Services.Queries.Models.Catalog;
Expand All @@ -11,6 +14,8 @@
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -22,6 +27,10 @@ public class GetVendorHandler : IRequestHandler<GetVendor, VendorModel>
private readonly IMediator _mediator;
private readonly IPictureService _pictureService;
private readonly ILocalizationService _localizationService;
private readonly ISpecificationAttributeService _specificationAttributeService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ICacheManager _cacheManager;
private readonly IWebHelper _webHelper;

private readonly VendorSettings _vendorSettings;
private readonly MediaSettings _mediaSettings;
Expand All @@ -33,13 +42,21 @@ public GetVendorHandler(
ILocalizationService localizationService,
VendorSettings vendorSettings,
MediaSettings mediaSettings,
ISpecificationAttributeService specificationAttributeService,
IHttpContextAccessor httpContextAccessor,
ICacheManager cacheManager,
IWebHelper webHelper,
CatalogSettings catalogSettings)
{
_mediator = mediator;
_pictureService = pictureService;
_localizationService = localizationService;
_vendorSettings = vendorSettings;
_mediaSettings = mediaSettings;
_specificationAttributeService = specificationAttributeService;
_httpContextAccessor = httpContextAccessor;
_cacheManager = cacheManager;
_webHelper = webHelper;
_catalogSettings = catalogSettings;
}

Expand Down Expand Up @@ -83,23 +100,34 @@ public async Task<VendorModel> Handle(GetVendor request, CancellationToken cance
});
model.PagingFilteringContext = options.command;

IList<string> alreadyFilteredSpecOptionIds = await model.PagingFilteringContext.SpecificationFilter.GetAlreadyFilteredSpecOptionIds
(_httpContextAccessor, _specificationAttributeService);

//products
var products = (await _mediator.Send(new GetSearchProductsQuery() {
LoadFilterableSpecificationAttributeOptionIds = !_catalogSettings.IgnoreFilterableSpecAttributeOption,
Customer = request.Customer,
VendorId = request.Vendor.Id,
StoreId = request.Store.Id,
FilteredSpecs = alreadyFilteredSpecOptionIds,
VisibleIndividuallyOnly = true,
OrderBy = (ProductSortingEnum)request.Command.OrderBy,
PageIndex = request.Command.PageNumber - 1,
PageSize = request.Command.PageSize
})).products;
}));

model.Products = (await _mediator.Send(new GetProductOverview() {
Products = products,
Products = products.products,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages
})).ToList();

model.PagingFilteringContext.LoadPagedList(products);
model.PagingFilteringContext.LoadPagedList(products.products);

//specs
await model.PagingFilteringContext.SpecificationFilter.PrepareSpecsFilters(alreadyFilteredSpecOptionIds,
products.filterableSpecificationAttributeOptionIds,
_specificationAttributeService, _webHelper, _cacheManager, request.Language.Id);

return model;
}
}
Expand Down
Loading

0 comments on commit 6cd731c

Please sign in to comment.