Developer forum

Forum » Templates » GetLoop( "Query.Parameters" ) in ProductListViewModel

GetLoop( "Query.Parameters" ) in ProductListViewModel

Jesper Holm Damgaard
Reply

Hi guys

I am in the process of converting an old product list template with template tags to the new product catalog using ProductListViewModel. I cannot seem to find any property or method that can give the data i used to find in the template tag GetLoop( "Query.Parameters" )

Am i mising something or i am supposed to get that from somewhere else?

--
All the best, Jesper


Replies

 
Nicolai Pedersen
Reply

Hi Jesper

You will get similar information from the FacetViewModel https://doc.dynamicweb.com/api/html/39bfd536-dd90-756c-06fe-852ea967ac3c.htm

On the ProductListViewModel.FacetGroups[0].Facets[0], i.e. ProductListViewModel.FacetGroups[0].Facets[0].QueryParameter which you are looking for.

Of course FacetGroups and Facets are IEnumerables, so you have to loop first one and then the other inside.

BR Nicolai

 
Jesper Holm Damgaard
Reply

Thanks, but i my case i am actually looking for all query parameters that are not used as facets. Here is the snippet from my old template:

@foreach ( LoopItem queryParameter in GetLoop( "Query.Parameters" ) )
{
  if ( string.IsNullOrEmpty( queryParameter.GetString( "Parameter.Value" ) ) == false )
  {
    if ( queryParameter.GetBoolean( "Parameter.IsHandledAsFacet" ) == false && queryParameter.GetString( "Parameter.Name" ) != "q" )
    {
      <input name="@queryParameter.GetString( "Parameter.Name" )" type="hidden" value="@HttpUtility.HtmlAttributeEncode( queryParameter.GetString( "Parameter.Value" ) )">
    }
  }
}

Is there any way to achieve that with the ProductListViewModel?

--
All the best, Jesper

 

You must be logged in to post in the forum