Developer forum

Forum » Development » eCom product list custom group

eCom product list custom group

Nuno Aguiar
Reply

Hi,

 

We have a solution for an eCommerce shoe shop, using two variants (size + color)

 

At first we were grouping the shoes by "main product" (shoe model) but now the client want to list all available colors. We cannot do this by simply changing the variant visibility settings in the paragraph to "Show all", because I would get all sizes + colors, and I cannot hide them in Razor or JS because it would mess up paging (unless someone can tell me how)

 

My option turns to a ProductListTemplateExtender

http://developer.dynamicweb-cms.com/documentation/for-developers/ecommerce/extensibility/template-extenders.aspx

 

Can we simply repopulate the ProductList object with the first instance of a variant option, without interfering with the paragraph settings and/or has someone developed a better solution for this?

 

Best Regards,

Nuno


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Nuno

We actually have it on our to-do to be able to do this. No firm plans yet, though

A product list template extender is not the way to go - that will just extend the template of the list. You should look into a productlistprovider instead.

Nicolai

Votes for this answer: 1
 
Nuno Aguiar
Reply

Hi Nicolai,

 

Will do, thanks

 

Nuno

 
Marco Santos
Reply

Hello.

How does this Product List Provider works exactly? Do you change event arguments to match you criteria and then call the base method (for OnProvide)? And how do you then specify the provider to use in the product catalog module?

Do you have an example handy that I could take a look at?

Marco

 
Morten Bengtson
Reply
This post has been marked as an answer

Hi Marco,

You need to implement a class that inherits from Dynamicweb.Extensibility.Provider.ProductListCollectionProvider. You should not use the ProductListProvider, which does absolutely nothing. I wonder why it hasn't been removed or at least marked as obsolete.

Anyway, you then need to override the FetchCollection method and return a collection of products - or return null if you don't have any products to provide and then eCommerce will fetch products as if there was no custom provider.

You can have multipe providers and the first one that returns a ProductCollection (not null) will be used.

 

public class MyCustomProductListCollectionProvider : ProductListCollectionProvider
{
    public override ProductCollection FetchCollection(Renderer renderer, string groups)
    {
        ProductCollection products = null;

        // TODO: Find out if you have any products to provide (lookup in database based on groups, settings, querystring or something else). If yes, return a ProductCollection with those products, otherwise just return null.

        return products;
    }
}
Votes for this answer: 1
 
Marco Santos
Reply

Hello.

So I have created a ProductListCollectionProvider and it does achieve what we want (all the colors for a shoe are displayed, without the duplicates fpor the diferent sizes), but it seems to be ignore the search filters that were applied.

So where before we had a product catalog in a page where if we searched for "Ballet" only the shoes with ballet on the name would be listed, now all the shoes are being shown. Is there an extra step to get the filtering back?

Thanks.

Marco

 
Nicolai Høeg Pedersen
Reply

Hi Marco

Yes, since you have a custom provider returning the result, Dynamicweb assumes you have averything under control.

What you can do is, in your provider to return nothing if there is a search in querystring.

So let your provider do something like

If request.querystring contains a search

return nothing

end if

Nice code, eh!

 
Marco Santos
Reply

Hello.

Almost there guys! The results are what we are looking for, but there is an issue with the list that is presented for filtering. We have a filter on a field that is a product category (a list of materials) and for which the products can have several items of.

When we get to the search results, the filters are displaying the materials that exist only in the results, as defined in the filter definition, but are also showing two aditional entries for the materials, and neither of them is part of any of the products that show up in the results, in any variant. It is, or at least it looks like, the values for the materials are coming from the collection provided our custom provider, as it is not showing every single material in the system. But maybe there is some additional processing that I am not aware of? What could be causing this?

Thanks.

Marco

 

You must be logged in to post in the forum