Skip to content

Commit

Permalink
chore: backport plugin to nopCommerce 420
Browse files Browse the repository at this point in the history
  • Loading branch information
mewajda committed Nov 13, 2020
1 parent 02515a0 commit ebf7ea8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 74 deletions.
12 changes: 2 additions & 10 deletions Nixtus.Plugin.Widgets.Lucene/Factories/CatalogModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ public class CatalogModelFactory : Nop.Web.Factories.CatalogModelFactory
private readonly IWorkContext _workContext;
private readonly MediaSettings _mediaSettings;
private readonly VendorSettings _vendorSettings;
private readonly ICustomerService _customerService;
private readonly ICacheKeyService _cacheKeyService;
private readonly IStaticCacheManager _staticCacheManager;

private readonly LuceneSettings _luceneSettings;
private readonly ILuceneService _luceneService;
Expand Down Expand Up @@ -105,18 +102,15 @@ public CatalogModelFactory(BlogSettings blogSettings,
IWorkContext workContext,
MediaSettings mediaSettings,
VendorSettings vendorSettings,
LuceneSettings luceneSettings, ILuceneService luceneService,
ICacheKeyService cacheKeyService, ICustomerService customerService, IStaticCacheManager staticCacheManager)
LuceneSettings luceneSettings, ILuceneService luceneService)
: base(blogSettings,
catalogSettings,
displayDefaultMenuItemSettings,
forumSettings,
actionContextAccessor,
cacheKeyService,
categoryService,
categoryTemplateService,
currencyService,
customerService,
eventPublisher,
httpContextAccessor,
localizationService,
Expand All @@ -129,7 +123,7 @@ public CatalogModelFactory(BlogSettings blogSettings,
productTagService,
searchTermService,
specificationAttributeService,
staticCacheManager,
cacheManager,
storeContext,
topicService,
urlHelperFactory,
Expand Down Expand Up @@ -170,8 +164,6 @@ public CatalogModelFactory(BlogSettings blogSettings,
_workContext = workContext;
_mediaSettings = mediaSettings;
_vendorSettings = vendorSettings;
_customerService = customerService;
_cacheKeyService = cacheKeyService;

_luceneSettings = luceneSettings;
_luceneService = luceneService;
Expand Down
26 changes: 3 additions & 23 deletions Nixtus.Plugin.Widgets.Lucene/Infrastructure/RouterProvider.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Nop.Core.Domain.Localization;
using Nop.Data;
using Nop.Services.Localization;
using Microsoft.AspNetCore.Routing;
using Nop.Web.Framework.Mvc.Routing;
using System.Linq;

namespace Nixtus.Plugin.Widgets.Lucene.Infrastructure
{
public class RouterProvider : IRouteProvider
{
public int Priority => 1;

public void RegisterRoutes(IEndpointRouteBuilder endpointRouteBuilder)
public void RegisterRoutes(IRouteBuilder endpointRouteBuilder)
{
var pattern = string.Empty;
if (DataSettingsManager.DatabaseIsInstalled)
{
var localizationSettings = endpointRouteBuilder.ServiceProvider.GetRequiredService<LocalizationSettings>();
if (localizationSettings.SeoFriendlyUrlsForLanguagesEnabled)
{
var langservice = endpointRouteBuilder.ServiceProvider.GetRequiredService<ILanguageService>();
var languages = langservice.GetAllLanguages().ToList();
pattern = "{language:lang=" + languages.FirstOrDefault().UniqueSeoCode + "}/";
}
}

// override autocomplete search
endpointRouteBuilder.MapControllerRoute("ProductSearchAutoComplete", $"{pattern}catalog/searchtermautocomplete",
new { controller = "LuceneCatalog", action = "SearchTermAutoComplete" });

}
}
}
23 changes: 8 additions & 15 deletions Nixtus.Plugin.Widgets.Lucene/LucenePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Nop.Services.Configuration;
using Nop.Services.Localization;
using Nop.Services.Plugins;
using System.Collections.Generic;

namespace Nixtus.Plugin.Widgets.Lucene
{
Expand Down Expand Up @@ -39,13 +38,10 @@ public override void Install()
_settingService.SaveSetting(settings);

//locales
_localizationService.AddPluginLocaleResource(new Dictionary<string, string>
{
{ "Plugins.Misc.Lucene.Fields.Enabled", "Enable Lucene search" },
{ "Plugins.Misc.Lucene.Fields.Enabled.Hint", "Turn on the Lucene Full-Text search funtionality" },
{ "Plugins.Misc.Lucene.Fields.AutoCompleteSearchEnabled", "Enable auto complete search" },
{ "Plugins.Misc.Lucene.Fields.AutoCompleteSearchEnabled.Hint", "Turn on the Lucene Full-Text search funtionality for auto complete" }
});
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.Misc.Lucene.Fields.Enabled", "Enabled Lucene search");
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.Misc.Lucene.Fields.Enabled.Hint", "Turn on the Lucene Full-Text search functionality");
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.Misc.Lucene.Fields.AutoCompleteSearchEnabled", "Enable auto complete search");
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.Misc.Lucene.Fields.AutoCompleteSearchEnabled.Hint", "Turn on the Lucene Full-Text search functionality for auto complete");

base.Install();
}
Expand All @@ -55,13 +51,10 @@ public override void Uninstall()
_settingService.DeleteSetting<LuceneSettings>();

//locales
_localizationService.DeletePluginLocaleResources(new List<string>
{
"Plugins.Misc.Lucene.Fields.Enabled",
"Plugins.Misc.Lucene.Fields.Enabled.Hint",
"Plugins.Misc.Lucene.Fields.AutoCompleteSearchEnabled",
"Plugins.Misc.Lucene.Fields.AutoCompleteSearchEnabled.Hint"
});
_localizationService.DeletePluginLocaleResource("Plugins.Misc.Lucene.Fields.Enabled");
_localizationService.DeletePluginLocaleResource("Plugins.Misc.Lucene.Fields.Enabled.Hint");
_localizationService.DeletePluginLocaleResource("Plugins.Misc.Lucene.Fields.AutoCompleteSearchEnabled");
_localizationService.DeletePluginLocaleResource("Plugins.Misc.Lucene.Fields.AutoCompleteSearchEnabled.Hint");

base.Uninstall();
}
Expand Down
29 changes: 6 additions & 23 deletions Nixtus.Plugin.Widgets.Lucene/Nixtus.Plugin.Widgets.Lucene.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Copyright>Copyright © Nixtus, LLC</Copyright>
<Company>Nixtus, LLC</Company>
<Authors>Nixtus, LLC</Authors>
Expand Down Expand Up @@ -36,28 +36,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Lucene.Net" Version="4.8.0-beta00011" />
<PackageReference Include="Lucene.Net.Analysis.Common" Version="4.8.0-beta00011" />
<PackageReference Include="Lucene.Net.Queries" Version="4.8.0-beta00011" />
<PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00011" />
</ItemGroup>

<ItemGroup>
<Reference Include="Lucene.Net">
<HintPath>..\..\Presentation\Nop.Web\Plugins\Misc.Lucene\Lucene.Net.dll</HintPath>
</Reference>
<Reference Include="Lucene.Net.Analysis.Common">
<HintPath>..\..\Presentation\Nop.Web\Plugins\Misc.Lucene\Lucene.Net.Analysis.Common.dll</HintPath>
</Reference>
<Reference Include="Lucene.Net.Queries">
<HintPath>..\..\Presentation\Nop.Web\Plugins\Misc.Lucene\Lucene.Net.Queries.dll</HintPath>
</Reference>
<Reference Include="Lucene.Net.QueryParser">
<HintPath>..\..\Presentation\Nop.Web\Plugins\Misc.Lucene\Lucene.Net.QueryParser.dll</HintPath>
</Reference>
<Reference Include="Lucene.Net.Sandbox">
<HintPath>..\..\Presentation\Nop.Web\Plugins\Misc.Lucene\Lucene.Net.Sandbox.dll</HintPath>
</Reference>
<PackageReference Include="Lucene.Net" Version="4.8.0-beta00006" />
<PackageReference Include="Lucene.Net.Analysis.Common" Version="4.8.0-beta00006" />
<PackageReference Include="Lucene.Net.Queries" Version="4.8.0-beta00006" />
<PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00006" />
<PackageReference Include="Lucene.Net.Sandbox" Version="4.8.0-beta00006" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Nixtus.Plugin.Widgets.Lucene/Services/LuceneService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using Lucene.Net.Util;
using Microsoft.AspNetCore.Http;
using Nop.Core;
using Nop.Core.Data;
using Nop.Core.Domain.Catalog;
using Nop.Core.Infrastructure;
using Nop.Data;
using Nop.Services.Catalog;
using Nop.Services.Logging;
using System;
Expand Down
4 changes: 2 additions & 2 deletions Nixtus.Plugin.Widgets.Lucene/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"Group": "Widgets",
"FriendlyName": "Lucene",
"SystemName": "Nixtus.Misc.Lucene",
"Version": "1.10",
"SupportedVersions": [ "4.30" ],
"Version": "0.90",
"SupportedVersions": [ "4.20" ],
"Author": "Nixtus, LLC",
"DisplayOrder": 1,
"FileName": "Nixtus.Plugin.Widgets.Lucene.dll",
Expand Down

0 comments on commit ebf7ea8

Please sign in to comment.