Skip to content

Commit 33150db

Browse files
committed
Refactoring
1 parent 63fb399 commit 33150db

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/VirtoCommerce.CatalogModule.Data/Services/CatalogSeoResolver.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ protected virtual async Task<List<SeoInfo>> SearchSeoInfos(string permalink, Sto
185185
}
186186

187187
var slug = segments.Last();
188-
189-
var entities = await SearchSeoInfoEntities(slug, store, criteria, isActive);
188+
var entities = await GetSeoInfoEntities(slug, store, criteria, isActive);
190189

191190
var categoryIds = entities.Select(x => x.CategoryId).Where(x => x != null).Distinct().ToArray();
192191
var seoList = new List<(string SeoPath, string OutlinePath, string Id)>();
@@ -241,16 +240,20 @@ protected virtual async Task<List<SeoInfo>> SearchSeoInfos(string permalink, Sto
241240
}
242241
}
243242

244-
protected virtual async Task<SeoInfoEntity[]> SearchSeoInfoEntities(string slug, Store store, SeoSearchCriteria criteria, bool isActive)
243+
protected virtual async Task<IList<SeoInfoEntity>> GetSeoInfoEntities(string slug, Store store, SeoSearchCriteria criteria, bool isActive)
245244
{
246245
using var repository = _repositoryFactory();
247-
return await repository.SeoInfos.Where(x =>
246+
return await GetSeoInfoQuery(repository, slug, store, criteria, isActive).ToListAsync();
247+
}
248+
249+
protected virtual IQueryable<SeoInfoEntity> GetSeoInfoQuery(ICatalogRepository repository, string slug, Store store, SeoSearchCriteria criteria, bool isActive)
250+
{
251+
return repository.SeoInfos.Where(x =>
248252
x.IsActive == isActive &&
249253
x.Keyword == slug &&
250254
(x.Category != null && x.Category.IsActive || x.Item != null && x.Item.IsActive || x.Catalog != null) &&
251255
(string.IsNullOrEmpty(x.StoreId) || x.StoreId == store.Id) &&
252-
(string.IsNullOrEmpty(x.Language) || x.Language == criteria.LanguageCode || x.Language == store.DefaultLanguage))
253-
.ToArrayAsync();
256+
(string.IsNullOrEmpty(x.Language) || x.Language == criteria.LanguageCode || x.Language == store.DefaultLanguage));
254257
}
255258

256259
protected static int GetSeoScore(SeoInfo seoInfo, Store store, SeoSearchCriteria criteria)

0 commit comments

Comments
 (0)