Developer forum

Forum » Templates » Number of products in filter search

Number of products in filter search

Thomas Schroll
Reply

Hi

I am trying to show the number of products available in a given filter. If I implement it in my Search template I can use the field Ecom:Search.Filter.Option.ResultsCountFormatted. However I would like to manually sort the filters, which is why I use a filter template. In my case I am filtering on a custom field and the filter type is 'Product field value'. All filters are checkbox based, so I would like to use the same filter template on all of them.

I have managed to get everything to work besides the number of products with the code below.

Could anyone tell me if it is possile to show the number of available products?

Regards Thomas

<div class="filter-wrapper @GetValue("Filters:Current.CssClass")">
	<h3>@GetValue("Filters:Current.Name")</h3>
	<div class="filter-content">
		<ul>
			@foreach (var filterOption in GetLoop("Ecom:Filters.ProductFields.Rows")){
				<li>
					<label for="chk@{@filterOption.GetValue("Filters:Current.TagName")@filterOption.GetValue("Ecom:Filters.ProductFields.Rows.LoopCounter")}">
						<input type="checkbox" class="filter-option-value" id="chk@{@filterOption.GetValue("Filters:Current.TagName")@filterOption.GetValue("Ecom:Filters.ProductFields.Rows.LoopCounter")}" name="@filterOption.GetValue("Filters:Current.TagName")" value="@filterOption.GetValue("Ecom:Filters.ProductFields.Row.Value")" @if(Dynamicweb.Input.FormatBoolean(filterOption.GetValue("Ecom:Filters.ProductFields.Row.Checked"))){<text> checked="checked"</text>} />
						@filterOption.GetValue("Ecom:Filters.ProductFields.Row.Text")
						<span class="badge">@filterOption.GetValue("Ecom:Search.Filter.Option.ResultsCountFormatted")</span>
					</label>
				</li>
			}
		</ul>
	</div> <!-- / .filter-container -->
</div> <!-- / .filter-wrapper -->

 

 

 

 

 


Replies

 
Mikkel Ricky
Reply

Have you tried @filterOption.GetValue("Ecom:Filters.ProductFields.Row.TotalFormatted")?

Inorder to see available values, you can get a DwTemplateTags-like view by adding

<pre>@string.Join("\n", filterOption.Values)</pre>

inside your loop. 

 

 
Thomas Schroll
Reply

Sorry. I totally missed that field.

Thanks Mikkel

Regards Thomas

 

 

 

You must be logged in to post in the forum