Developer forum

Forum » Ecommerce - Standard features » Listing Catalog Publishing Items

Listing Catalog Publishing Items

Martin Amsinck Andersen
Reply

Hello!

I'm currently developing a Webshop with the eCommerce version of DW, and im kinda stuck here. 
We have implemented the Catalog Publishing functionality, and it works.

My issue now is that, i need to list all the products in the Catalog, in a nested list ( Product Category => Products), on a page.

How would i go about fetching the data for this list?

Thanx in advance
Martin


Replies

 
Thomas Schroll
Reply

Hi Martin

In razor you can use linq. Do something like:

@{
    var products = GetLoop("Products").GroupBy(p => p.GetString("Ecom:Product.PrimaryOrFirstGroupID"));
}

<ul>

@foreach (var group in products.OrderBy(g=>Group.GetGroupByID(g.Key).Name)) {
        <li>@Group.GetGroupByID(group.Key).Name
<ul>
        @foreach (var product in group) {

<li>@product.GetString("Ecom:Product.Name")<li>

}

</ul>

</li>

}

</ul>

In the above groups are ordered alphabetically.

Regards Thomas

 

 
Martin Amsinck Andersen
Reply

Hi Thomas

Thank you for your answer.

But this will give me a ordered list of all products in the Product Catalog, not the current user Catalog Publishing Products(http://manual.dynamicweb-cms.com/Dynamicweb-eCommerce/Modules/Product-Catalog/Catalog-publishing.aspx)

What i need is a plain page, with all Catalog Publishing Products for the current user. 

How do i add a module to the backend getting these data? 

 

 

 
Thomas Schroll
Reply

Hi Martin

I haven't much experience with the catalog publishing module, but I suspect you can do the same. You probably need to use 'DwShopGroupName' instead of 'Ecom:Product.PrimaryOrFirstGroupID'. You can use @TemplateTags() to see which tags are available.

Regards Thomas

 
Martin Amsinck Andersen
Reply

Hi Thomas, thx again. 

I'll try that.

Regarding template tags, I Currently have an empty page, så the TempalteTags is relativly empty, i need to find out a way to get the products from the catalog publishing in a loop on the page. I hope that somebody else can help me with this. 

 
Thomas Schroll
Reply

Hi Martin

TemplateTags shows all available tags in the current template. If you insert the tag in the catalog publisher templates you should be able to see the available tags. If you wish to see the tags in a loop, you should place the TemplateTags tag inside the loop like this:

@foreach(var product in GetLoop("Products")){

@product.TemplateTags()

}

Regards Thomas

 
Martin Amsinck Andersen
Reply

Yes i got that :) 

what i need, is to be able to create the loop with the CatalogPublishingProducts, is there a way to do this?

 
Thomas Schroll
Reply

I think you need to create a template extender, but that is beyond my capabilities. You could also have a look at the api (http://developer.dynamicweb-cms.com/api8/) to see if you can get the data in another way.

Regards Thomas

 
Martin Amsinck Andersen
Reply

Thank you, i'll try that :)

 

You must be logged in to post in the forum