@model ProductsByTagModel

@using Nop.Core
@using Nop.Core.Domain.Catalog
@using Nop.Core.Domain.Seo

@inject IWebHelper webHelper
@inject SeoSettings seoSettings

@{
    Layout = "_ColumnsTwo";

    //title
    NopHtml.AddTitleParts(string.Format(T("PageTitle.ProductsByTag").Text, Model.TagName));
    //page class
    NopHtml.AppendPageCssClassParts("html-product-tag-page");

    //canonical URL
    if (seoSettings.CanonicalUrlsEnabled)
    {
        var productsByTagUrl = Url.RouteUrl<ProductTag>(new { SeName = Model.TagSeName }, webHelper.GetCurrentRequestProtocol()).ToLowerInvariant();
        NopHtml.AddCanonicalUrlParts(productsByTagUrl, seoSettings.QueryStringInCanonicalUrlsEnabled);
    }
}

@section CatalogFilters {
    @await Html.PartialAsync("_CatalogFilters", Model.CatalogProductsModel)
}

<div class="page product-tag-page">
    <div class="page-title">
        <h1>@string.Format(T("Products.Tags.ProductsTaggedWith").Text, Model.TagName)</h1>
    </div>
    <div class="page-body">
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.ProductsByTagTop, additionalData = Model })
        @await Html.PartialAsync("_CatalogSelectors", Model.CatalogProductsModel)
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.ProductsByTagBeforeProductList, additionalData = Model })
        @{
            var catalogProductsViewData = new ViewDataDictionary(ViewData);
            catalogProductsViewData["fetchUrl"] = Html.Raw(Url.RouteUrl("GetTagProducts", new { tagId = Model.Id }));
        }
        @await Html.PartialAsync("_CatalogProducts", Model.CatalogProductsModel, catalogProductsViewData)
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.ProductsByTagBottom, additionalData = Model })
    </div>
</div>