Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

SearchPluginManager.cs

?using Nop.Core.Domain.Catalog;
using Nop.Core.Domain.Customers;
using Nop.Services.Customers;
using Nop.Services.Plugins;

 namespace Nop.Services.Catalog; 

 /// 
 /// Represents a search plugin manager implementation
 /// 
 public partial class SearchPluginManager : PluginManager, ISearchPluginManager
 {
     #region Fields

     protected readonly CatalogSettings _catalogSettings;

     #endregion

     #region Ctor

     public SearchPluginManager(CatalogSettings catalogSettings, ICustomerService customerService, IPluginService pluginService)
         : base(customerService, pluginService)
     {
         _catalogSettings = catalogSettings;
     }

     #endregion

     #region Methods

     /// 
     /// Load primary active search provider
     /// 
     /// Filter by customer; pass null to load all plugins
     /// Filter by store; pass 0 to load all plugins
     /// 
     /// A task that represents the asynchronous operation
     /// The task result contains the search provider
     /// 
     public virtual async Task LoadPrimaryPluginAsync(Customer customer = null, int storeId = 0)
     {
         if (string.IsNullOrEmpty(_catalogSettings.ActiveSearchProviderSystemName))
             return null;

         return await LoadPrimaryPluginAsync(_catalogSettings.ActiveSearchProviderSystemName, customer, storeId);
     }

     /// 
     /// Check whether the passed search provider is active
     /// 
     /// Search provider to check
     /// Result
     public virtual bool IsPluginActive(ISearchProvider searchProvider)
     {
         return IsPluginActive(searchProvider, [_catalogSettings.ActiveSearchProviderSystemName]);
     }

     /// 
     /// Check whether the search provider with the passed system name is active
     /// 
     /// System name of search provider to check
     /// Filter by customer; pass null to load all plugins
     /// Filter by store; pass 0 to load all plugins
     /// 
     /// A task that represents the asynchronous operation
     /// The task result contains the result
     /// 
     public virtual async Task IsPluginActiveAsync(string systemName, Customer customer = null, int storeId = 0)
     {
         var searchProvider = await LoadPluginBySystemNameAsync(systemName, customer, storeId);
         return IsPluginActive(searchProvider);
     }

     #endregion
 }