Error executing template "Designs/Swift-v2/eCom/ProductCatalog/CmgtIgnite_ProductCarouselWithComponents.cshtml"
System.ArgumentException: Paragraph ID must be greater than 0, but it was 0
   at Dynamicweb.Core.Ensure.That[TException](Boolean condition, String message)
   at Dynamicweb.Content.ParagraphService.GetParagraph(Int32 paragraphId)
   at CompiledRazorTemplates.Dynamic.RazorEngine_273efab8835c4e5d876bb2500020214d.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)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits ViewModelTemplate<ProductListViewModel> 2 @using Dynamicweb.Frontend 3 @using Dynamicweb.Rendering 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Environment 6 7 8 @functions 9 { 10 private string RenderIgniteIcon(string icon) 11 { 12 if (icon.EndsWith(".svg", StringComparison.OrdinalIgnoreCase) && !icon.EndsWith("none.svg", StringComparison.OrdinalIgnoreCase)) 13 { 14 string iconPath = Dynamicweb.Context.Current.Server.MapPath(icon); 15 16 return $"<span class=\"ignite-icon\">{ReadFile(iconPath)}</span>"; 17 } 18 else 19 { 20 return string.Empty; 21 } 22 } 23 private string RenderIgniteSvg(string icon) 24 { 25 if (icon.EndsWith(".svg", StringComparison.OrdinalIgnoreCase) && !icon.EndsWith("none.svg", StringComparison.OrdinalIgnoreCase)) 26 { 27 string iconPath = Dynamicweb.Context.Current.Server.MapPath(icon); 28 29 return $"<span class=\"ignite-svg\">{ReadFile(iconPath)}</span>"; 30 } 31 else 32 { 33 return string.Empty; 34 } 35 } 36 } 37 38 39 @functions { 40 41 public ProductViewModel GetDummyProduct() 42 { 43 ProductViewModel product = null; 44 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 45 { 46 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 47 } 48 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 49 { 50 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 51 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 52 53 if (productList?.Products is object) 54 { 55 product = productList.Products[0]; 56 } 57 } 58 59 return product; 60 } 61 62 } 63 64 @{ 65 string googleTagManagerID = Pageview.AreaSettings.GetString("GoogleTagManagerID"); 66 string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID"); 67 68 bool allowTracking = true; 69 if (CookieManager.IsCookieManagementActive) 70 { 71 var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); 72 allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical")); 73 } 74 75 int paragraphId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("ParagraphId")) ? Convert.ToInt32(Dynamicweb.Context.Current.Request.Form.Get("ParagraphId")) : 0; 76 var paragraph = Dynamicweb.Content.Services.Paragraphs?.GetParagraph(paragraphId) ?? null; 77 ParagraphInfoViewModel paragraphViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreateParagraphInfoViewModel(paragraph); 78 79 int itemSourcePageId = Convert.ToInt32(paragraphViewModel.Item.GetRawValueString("ListComponentSource", "0")); 80 81 var pageService = new Dynamicweb.Content.PageService(); 82 itemSourcePageId = itemSourcePageId > 0 && pageService.GetPageOrLanguage(itemSourcePageId, Pageview.AreaID) != null ? pageService.GetPageOrLanguage(itemSourcePageId, Pageview.AreaID).ID : itemSourcePageId; 83 84 var page = itemSourcePageId != 0 ? Dynamicweb.Content.Services.Pages.GetPage(itemSourcePageId) : null; 85 86 //Carousel Options 87 int desktopColumns = Dynamicweb.Core.Converter.ToInt32(paragraphViewModel.Item.GetRawValueString("DesktopColumns", "5")); 88 string mobileColumns = paragraphViewModel.Item.GetRawValueString("MobileColumns", "1"); 89 int gap = Convert.ToInt32(paragraphViewModel.Item.GetRawValueString("Gap", "0")); 90 string icon = !string.IsNullOrEmpty(paragraphViewModel.Item.GetRawValueString("Icon")) ? paragraphViewModel.Item.GetRawValueString("Icon") : string.Empty; 91 string iconSize = paragraphViewModel.Item.GetRawValueString("IconSize", "1.5"); 92 bool overflowing = Convert.ToBoolean(paragraphViewModel.Item.GetRawValueString("Overflowing", "False")); 93 string overflowingCss = overflowing ? "overflowing" : string.Empty; 94 95 // Styling 96 string theme = !string.IsNullOrWhiteSpace(paragraphViewModel.Item.GetRawValueString("Theme")) ? $"theme {paragraphViewModel.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower()}" : string.Empty; 97 string itemTheme = !string.IsNullOrWhiteSpace(paragraphViewModel.Item.GetRawValueString("ItemTheme")) ? $"theme {paragraphViewModel.Item.GetRawValueString("ItemTheme").Replace(" ", "").Trim().ToLower()}" : string.Empty; 98 99 //Carousel Icon Style Attribute 100 var styleIconVariableCollection = new List<string>(); 101 styleIconVariableCollection.Add($"--ignite-icon-size: {iconSize}rem"); 102 string iconVariables = string.Join(";", styleIconVariableCollection).Trim(); 103 104 //Carousel Style Attribute 105 var itemStyleCollection = new List<string>(); 106 itemStyleCollection.Add($"--desktop-items: {desktopColumns}"); 107 itemStyleCollection.Add($"--mobile-items: {mobileColumns}"); 108 itemStyleCollection.Add($"--desktop-gap: var(--ignite-gap-{gap})"); 109 if (gap < 2) 110 { 111 itemStyleCollection.Add($"--mobile-gap: var(--ignite-gap-{gap})"); 112 } 113 else 114 { 115 itemStyleCollection.Add($"--mobile-gap: var(--ignite-gap-2)"); 116 } 117 118 string itemStyle = string.Join(";", itemStyleCollection).Trim(); 119 } 120 121 @if (paragraphViewModel != null && page != null) 122 { 123 if (Model.Products.Any()) 124 { 125 string sourceType = paragraphViewModel.Item.GetRawValueString("RelationType", "Trending"); 126 int modelId = paragraphViewModel.ID; 127 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 128 129 string listItemPadding = pageViewModel.Item.GetRawValueString("ContentPadding", string.Empty); 130 string listItemPaddingClass = string.Empty; 131 132 switch (listItemPadding) 133 { 134 case "small": 135 listItemPaddingClass = " p-2 p-xl-3"; 136 break; 137 case "large": 138 listItemPaddingClass = " p-3 p-xl-4"; 139 break; 140 case "small-x": 141 listItemPaddingClass = " px-2 px-md-3"; 142 break; 143 case "large-x": 144 listItemPaddingClass = " px-3 px-md-4"; 145 break; 146 } 147 148 if (sourceType == "selected") 149 { 150 string productIds = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("MainProductID")) ? Dynamicweb.Context.Current.Request.Form.Get("MainProductID") : string.Empty; 151 productIds = string.IsNullOrEmpty(productIds) ? Dynamicweb.Context.Current.Request.Form.Get("ProductVariantId") : productIds; 152 153 Model.Products = Model.Products.OrderBy(product => productIds.IndexOf(product.Id)).ToList(); 154 } 155 156 <div class="ignite-carousel @(theme) @(overflowingCss)" style="@(itemStyle);"> 157 <div class="track"> 158 @foreach (ProductViewModel product in Model.Products) 159 { 160 string link = product.GetProductLink(GetPageIdByNavigationTag("Shop"), false); 161 162 string clickProductLink = string.Empty; 163 if ((!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) || !string.IsNullOrWhiteSpace(googleTagManagerID)) && allowTracking) 164 { 165 clickProductLink = "onclick=\"return clickProductLink('" + @product.Id + "', '" + @product.Name + "', '" + @product.VariantName + "', '" + @product.Price.CurrencyCode + "', '" + @product.Price.Price + "')\""; 166 } 167 168 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 169 { 170 Dynamicweb.Context.Current.Items["ProductDetails"] = product; 171 } 172 else 173 { 174 Dynamicweb.Context.Current.Items.Add("ProductDetails", product); 175 } 176 177 <article class="item @(itemTheme) @listItemPaddingClass"> 178 @*<a href="@link" class="stretched-link" @clickProductLink> 179 <span class="visually-hidden">@product.Name</span> 180 </a>*@ 181 @{ 182 @RenderGrid(itemSourcePageId) 183 } 184 </article> 185 } 186 187 @if (!Model.Products.Any() && Pageview.IsVisualEditorMode) 188 { 189 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 190 { 191 Dynamicweb.Context.Current.Items["ProductDetails"] = GetDummyProduct(); 192 } 193 else 194 { 195 Dynamicweb.Context.Current.Items.Add("ProductDetails", GetDummyProduct()); 196 } 197 198 for (int i = 0; i < 4; i++) 199 { 200 <li class="d-flex flex-column"> 201 @{ 202 @RenderGrid(itemSourcePageId) 203 } 204 </li> 205 } 206 } 207 </div> 208 <button class="btn prev arrow position-absolute" aria-label="show previous carousel items" 209 style="@(iconVariables);display: none;color: #000;"> 210 @if (string.IsNullOrEmpty(icon)) 211 { 212 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24" fill="currentColor"> 213 <path 214 d="M646-440H200q-17 0-28.5-11.5T160-480q0-17 11.5-28.5T200-520h446L532-634q-12-12-11.5-28t11.5-28q12-12 28.5-12.5T589-691l183 183q6 6 8.5 13t2.5 15q0 8-2.5 15t-8.5 13L589-269q-12 12-28.5 11.5T532-270q-11-12-11.5-28t11.5-28l114-114Z"/> 215 </svg> 216 } 217 else 218 { 219 @RenderIgniteIcon(icon) 220 } 221 <span class="visually-hidden">@Translate("Previous")</span> 222 </button> 223 <button class="btn next arrow position-absolute" aria-label="show next carousel items" 224 style="@(iconVariables);color:#000;"> 225 @if (string.IsNullOrEmpty(icon)) 226 { 227 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24" fill="currentColor"> 228 <path 229 d="M646-440H200q-17 0-28.5-11.5T160-480q0-17 11.5-28.5T200-520h446L532-634q-12-12-11.5-28t11.5-28q12-12 28.5-12.5T589-691l183 183q6 6 8.5 13t2.5 15q0 8-2.5 15t-8.5 13L589-269q-12 12-28.5 11.5T532-270q-11-12-11.5-28t11.5-28l114-114Z"/> 230 </svg> 231 } 232 else 233 { 234 @RenderIgniteIcon(icon) 235 } 236 <span class="visually-hidden">@Translate("Next")</span> 237 </button> 238 </div> 239 } 240 } 241 else if (Pageview.IsVisualEditorMode == true) 242 { 243 <div class="alert alert-dark" role="alert"> 244 <span>@Translate("Product component slider: The slider will be rendered here, if there is anything to show")</span> 245 </div> 246 } 247 248 249 250 251