vc-module-catalog
vc-module-catalog copied to clipboard
Could not find Category by code if category is empty
We could not find category id by code if category is empty
Expected behavior
Find category by code if category is empty
Actual behavior
Categories is empty. I see result if I add any product into category.
Steps to reproduce
private readonly ICatalogSearchService _searchService;
var searchCreteria = new SearchCriteria
{
ResponseGroup = SearchResponseGroup.WithCategories,
Code = categoryCode,
CatalogId = catalogId,
Take = 1,
Skip = 0,
SearchInChildren = true
};
var result = _searchService.Search(searchCreteria);
result.Categories.FirstOrDefault();
I used workaround
private readonly Func<ICatalogRepository> _catalogRepositoryFactory;
using (var catalogRepository = _catalogRepositoryFactory())
{
return catalogRepository.Categories.Where(c => c.CatalogId == catalogId && c.Code == categoryCode).Select(c => c.Id).FirstOrDefault();
}