Nike, Inc. All rights reserved
Sort by
Brand
Gender
Color
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_ProductListItemRepeater.cshtml"
System.DivideByZeroException: Attempted to divide by zero.
   at System.Decimal.DecCalc.VarDecDiv(DecCalc& d1, DecCalc& d2)
   at Dynamicweb.Ecommerce.Prices.Internal.PriceSelectionService.Calculate(PriceCalculated calculated, PriceContext context) in E:\dw10agent\_w\2\s\src\Features\Ecommerce\Dynamicweb.Ecommerce\Prices\Internal\PriceSelectionService.cs:line 144
   at Dynamicweb.Ecommerce.Prices.PriceManager.GetPrice(PriceContext context, Product product, String unitId, Int64 stockLocationId) in E:\dw10agent\_w\2\s\src\Features\Ecommerce\Dynamicweb.Ecommerce\Prices\PriceManager.cs:line 153
   at Dynamicweb.Ecommerce.Orders.Discounts.DiscountService.GetProductDiscountPrice(PriceContext context, Product product, IEnumerable`1 validDiscounts, String unitId, Int64 stockLocationId) in E:\dw10agent\_w\2\s\src\Features\Ecommerce\Dynamicweb.Ecommerce\Orders\Discounts\DiscountService.cs:line 338
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetDiscountInfo(PriceViewModelSettings settings, Product product) in E:\dw10agent\_w\2\s\src\Features\Ecommerce\Dynamicweb.Ecommerce\ProductCatalog\ViewEngine.cs:line 2320
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.CreateValue()
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass19_3.<BulkCreateView>b__67() in E:\dw10agent\_w\2\s\src\Features\Ecommerce\Dynamicweb.Ecommerce\ProductCatalog\ViewEngine.cs:line 185
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.CreateValue()
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass19_3.<BulkCreateView>b__69() in E:\dw10agent\_w\2\s\src\Features\Ecommerce\Dynamicweb.Ecommerce\ProductCatalog\ViewEngine.cs:line 188
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.CreateValue()
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass19_3.<BulkCreateView>b__70() in E:\dw10agent\_w\2\s\src\Features\Ecommerce\Dynamicweb.Ecommerce\ProductCatalog\ViewEngine.cs:line 189
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.CreateValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_000620b971504d1898fd6a5f4663df5a.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 68
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 14
   at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 847

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> @using Dynamicweb.Ecommerce.ProductCatalog @using Dynamicweb.Core @{ int productsCount = 0; int maxProductsCounter = 0; ProductListViewModel? productList = null; if (Dynamicweb.Context.Current is not null && Dynamicweb.Context.Current.Items.Contains("ProductList")) { productList = (ProductListViewModel?)Dynamicweb.Context.Current.Items["ProductList"]; } } @if (productList is not null) { <div class="h-100 product-list" data-dw-colorscheme="@Model.ColorScheme?.Id"> @{ bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current?.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; string groupId = productList?.Group?.Id != null ? productList.Group.Id : ""; if (productList?.TotalProductsCount > 0) { int pageSizeSetting = Converter.ToInt32(Dynamicweb.Context.Current?.Request.QueryString.Get("OriginalPageSize")) > 0 ? Converter.ToInt32(Dynamicweb.Context.Current.Request.QueryString.Get("OriginalPageSize")) : productList.PageSize; int pageNumber = Converter.ToInt32(Dynamicweb.Context.Current?.Request.QueryString.Get("PageNum")) > 0 ? Converter.ToInt32(Dynamicweb.Context.Current.Request.QueryString.Get("PageNum")) : productList.CurrentPage; int pageSize = Converter.ToInt32(Dynamicweb.Context.Current?.Request.QueryString.Get("PageSize")) > 0 ? Converter.ToInt32(Dynamicweb.Context.Current.Request.QueryString.Get("PageSize")) : productList.PageSize; pageNumber = pageSize != pageSizeSetting ? (pageSize / pageSizeSetting) : pageNumber; int loadedProducts = productList.PageSize > productList.TotalProductsCount ? productList.TotalProductsCount : pageSizeSetting * pageNumber; loadedProducts = loadedProducts > productList.TotalProductsCount ? productList.TotalProductsCount : loadedProducts; pageNumber += 1; string? searchQuery = Dynamicweb.Context.Current?.Request["q"]; string? searchLayout = Dynamicweb.Context.Current?.Request.QueryString.Get("SearchLayout"); int itemSourcePageId = Convert.ToInt32(Model.Item?.GetRawValueString("ListComponentSource", "0")); itemSourcePageId = Dynamicweb.Content.Services.Pages.GetPageOrLanguage(itemSourcePageId, Pageview.AreaID)?.ID ?? itemSourcePageId; var page = Dynamicweb.Content.Services.Pages.GetPage(itemSourcePageId); if (page != null) { var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); string? gridColumnSize = Model.Item?.GetRawValueString("GridLayoutDesktop", "3-columns"); gridColumnSize = gridColumnSize == "2-columns" ? "g-col-lg-6" : gridColumnSize; gridColumnSize = gridColumnSize == "3-columns" ? "g-col-lg-4" : gridColumnSize; gridColumnSize = gridColumnSize == "4-columns" ? "g-col-lg-3" : gridColumnSize; gridColumnSize = gridColumnSize == "6-columns" ? "g-col-lg-2" : gridColumnSize; gridColumnSize = gridColumnSize == "list" ? "g-col-lg-12" : gridColumnSize; string? gridColumnMobileSize = Model.Item?.GetRawValueString("GridLayoutMobile", "2-columns"); gridColumnMobileSize = gridColumnMobileSize == "list" ? "g-col-12" : gridColumnMobileSize; gridColumnMobileSize = gridColumnMobileSize == "2-columns" ? "g-col-6" : gridColumnMobileSize; <div class="grid pb-3"> <script> window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: "view_item_list", ecommerce: { item_list_id: "product_list_item_repeater", item_list_name: "Product list (Item Repeater)", items: [ @foreach (ProductViewModel product in productList.Products) { <text>{ item_id: "@product.Number", item_name: "@Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(product.Name)", currency: "@product.Price.CurrencyCode", price: @product.Price.ToStringInvariant(), discount: @product.Discount.ToStringInvariant() },</text> } ] } }); </script> @foreach (ProductViewModel product in productList.Products) { if (maxProductsCounter == 0 || (productsCount < maxProductsCounter)) { string link = product.GetProductLink(GetPageIdByNavigationTag("Shop"), false); if (Dynamicweb.Context.Current?.Items.Contains("ProductDetails") != null) { Dynamicweb.Context.Current.Items["ProductDetails"] = product; } else { Dynamicweb.Context.Current?.Items.Add("ProductDetails", product); } if (Model.Item?.GetString("ListComponentSource") != null) { <article class="@gridColumnMobileSize @gridColumnSize d-flex flex-column position-relative product js-product" data-product-id="@product.Id" data-variant-id="@product.VariantId" itemscope itemtype="https://schema.org/Product"> @{ string clickProductLink = $"return clickProductLink('{product.Id}', '{Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(product.Name)}', '{Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(product.VariantName)}', '{product.Price.CurrencyCode}', '{product.Price.ToStringInvariant()}', '{product.Discount.ToStringInvariant()}')"; } <a href="@link" class="stretched-link" onmouseenter="swift.Image.swapImage(event)" onmouseout="swift.Image.swapImage(event)" onclick="@clickProductLink"> <span class="visually-hidden">@product.Name</span> </a> <script> function clickProductLink(productId, productName, productVariant, productCurrency, productPrice, productDiscount) { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: "select_item", ecommerce: { item_list_id: "product_list_item_repeater", item_list_name: "Product list (Item Repeater)", items: [ { item_id: productId, item_name: productName, currency: productCurrency, item_list_id: "product_list_item_repeater", item_list_name: "Product list (Item Repeater)", item_variant: productVariant, price: productPrice, discount: productDiscount } ] } }); } </script> @RenderGrid(itemSourcePageId) </article> } productsCount++; } } </div> <div class="my-3" id="ProductListLoadMore"> <div class="text-center"> <div class="opacity-85 mb-3">@loadedProducts @Translate("out of") @productList.TotalProductsCount @Translate("products")</div> @if (productList.PageCount != 1 && maxProductsCounter == 0 && loadedProducts < productList.TotalProductsCount) { string? sortBySelection = Dynamicweb.Context.Current?.Request.Form["SortBy"] ?? ""; sortBySelection = Dynamicweb.Context.Current?.Request.QueryString.Get("SortBy") ?? sortBySelection; string? mainProductId = Dynamicweb.Context.Current?.Request.QueryString.Get("MainProductID"); <form method="get" data-response-target-element=".product-list" data-swap="afterend" class="w-100"> @if (productList?.FacetGroups != null) { foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) { foreach (FacetViewModel facetItem in facetGroup.Facets) { foreach (FacetOptionViewModel facetOption in facetItem.Options) { if (facetOption.Selected) { <input type="hidden" name="@facetItem.QueryParameter" value="[@facetOption.Value]"> } } } } } @if (!string.IsNullOrEmpty(searchQuery)) { <input type="hidden" name="q" value="@searchQuery"> <input type="hidden" name="SearchLayout" value="@searchLayout"> } @if (!string.IsNullOrEmpty(mainProductId)) { <input type="hidden" name="MainProductID" value="@mainProductId"> } @if (productList?.Group?.Id != null) { <input type="hidden" name="GroupId" value="@groupId"> } <input type="hidden" name="OriginalPageSize" value="@pageSizeSetting"> <input type="hidden" name="PageSize" value="@(loadedProducts + pageSizeSetting)"> <input type="hidden" name="PageNum" value="@pageNumber"> <input type="hidden" name="SortBy" value="@sortBySelection"> <input type="hidden" name="RequestType" value="UpdateList"> <input type="hidden" name="ParagraphID" value="@Model.ID"> @if (productList?.FacetGroups is object) { string nextPageLink = $"/Default.aspx?ID={Model.PageID}&PageNum={pageNumber}&SortBy={sortBySelection}"; foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) { foreach (FacetViewModel facetItem in facetGroup.Facets) { foreach (FacetOptionViewModel facetOption in facetItem.Options) { if (facetOption.Selected) { nextPageLink += "&" + facetItem.QueryParameter + "=[" + facetOption.Value + "]"; } } } } nextPageLink += !string.IsNullOrEmpty(searchQuery) ? "&q=" + searchQuery : ""; <a href="@nextPageLink" class="btn btn-primary swift_load_more_button" data-dw-button="primary" onclick="swift.ProductList.Update(event)" id="LoadMoreButton_@Model.ID">@Translate("Load more products")</a> } </form> } </div> </div> <script> function switchVariantProduct(id, price, imagesrc) { var productImageElement = document.querySelector("#ProductImage_" + id); var productPriceElement = document.querySelector("#ProductPrice_" + id + " .text-price"); if (productPriceElement) { productPriceElement.innerText = price; } if (productImageElement) { productImageElement.src = imagesrc; var imageSrcset = productImageElement.srcset; imageSrcset = imageSrcset.replace(/image=.*?&/g, 'image=' + imagesrc + "&"); productImageElement.srcset = imageSrcset; } } </script> } else if (Pageview.IsVisualEditorMode) { <div class="alert alert-dark m-0" role="alert"> <span>@Translate("The selected component does not exist anymore")</span> </div> } } else { string? noProductsFoundMessage = null; if(Model.Item?.TryGetString("NoProductsFoundMessage", out var message) is true && !string.IsNullOrEmpty(message)) { noProductsFoundMessage = message; } else { noProductsFoundMessage = Translate("No products found"); } bool hasSubgroups = false; if (productList?.SubGroups != null) { hasSubgroups = productList.SubGroups.Any(); } if (Model.Item is not null && !Model.Item.GetBoolean("HideNoProductsFoundMessage")) { if (!isVisualEditor) { string emptyStateUrl = Pageview.SearchFriendlyUrl ?? string.Empty; emptyStateUrl = emptyStateUrl.LastIndexOf("?") != -1 ? emptyStateUrl.Substring(0, emptyStateUrl.LastIndexOf("?")) : emptyStateUrl; if (Dynamicweb.Context.Current?.Request.QueryString.Get("GroupID") is string groupIdQueryValue) { emptyStateUrl += "?GroupID=" + groupIdQueryValue; } bool hasActiveFacets = productList?.FacetGroups != null && productList.FacetGroups.Any(fg => fg.Facets.Any(f => f.OptionActiveCount > 0)); <div data-swift-text class="border border-2 rounded-3 text-center p-5 mx-auto" style="--bs-border-style: dashed;"> <div data-swift-empty-state> <div data-swift-empty-state-icon> <span class="icon"> @ReadFile("/Files/Images/Icons/filter.svg") </span> </div> </div> <h5 class="mb-2">@noProductsFoundMessage</h5> <p class="text-muted m-0">@Translate("Try clearing filters, or widen your search")</p> @if (hasActiveFacets) { <form method="get" action="@emptyStateUrl" data-response-target-element="content" class="d-inline-block"> <input type="hidden" name="RequestType" value="UpdateList"> <button type="button" class="btn badge badge-neutral-light hstack gap-2" data-dw-button onclick="swift.ProductList.Update(event)"> <span class="icon">@ReadFile("/Files/Images/Icons/xmark.svg")</span> @Translate("Clear all filters") </button> </form> } </div> } else { <div class="alert alert-dark m-0" role="alert"> @Translate("Product list: The list will be shown here, if any") </div> } } else if (!hasSubgroups) { <div class="alert alert-dark m-0" role="alert"> @noProductsFoundMessage </div> } } } </div> } else if (Pageview.IsVisualEditorMode) { <div class="alert alert-dark m-0" role="alert"> <span>@Translate("Product list item repeater: The repeater paragraph will be shown here, if any products are available")</span> </div> }