Hello,
Is there a function how I can get the ID of the currently displayed category?
Best regarde
@await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CategoryDetailsBeforeProductList, additionalData = Model })
@{
var catalogProductsViewData = new ViewDataDictionary(ViewData);
catalogProductsViewData["fetchUrl"] = Html.Raw(Url.Action("GetCategoryProducts", "Catalog", new { categoryId = Model.Id }));
}
public async Task<int?> GetCategoryIdByUrlSlug(string slug)
{
// find record by the URL slug
var urlRecord = await _urlRecordService.GetBySlugAsync(slug);
if (urlRecord==null || urlRecord.EntityName!=nameof(Category))
return null;
return urlRecord.EntityId;
}