Developer forum

Forum » Development » Order Products with ProductListCollectionProvider

Order Products with ProductListCollectionProvider

Nuno Aguiar
Reply
Hi,

We are trying to order products (by the settings in the paragraph) when getting them through a ProductListCollectionProvider, with no luck. Any ideas? (Dynamicweb 7.2)

The problem is that when we include the useOrderBy parameter, the collection is empty. We really need an urgent answer. Can anyone help us?

public class PublishedProductsProvider : Dynamicweb.Extensibility.Provider.ProductListCollectionProvider
{
        public override ProductCollection FetchCollection(Renderer renderer, string groups)
        {
                foreach (Product product in Product.getProducts(groups, true))
                {
                    //perform some tasks
                }
        }
}

Nuno

Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Nuno

ProductListCollectionProvider results are sorted automatically based on the settings on the Paragraph. I'm not sure where you're getting the UseOrderBy parameter, but if you're setting a property with this name I think you're using a ProductListProvider instead. This concept is not implemented completely, and therefore should not be used.

Hope this helps, otherwise please let me know if I misunderstood you :)

- Jeppe

Votes for this answer: 0
 
Nuno Aguiar
Reply
Hi Jeppe,

I initially though they were already sorted, but it's not working. Take a look at our code, to see if you can spot the problem.

Nuno

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

I have just created my own dll with your code and done some testing.

I created two Product Fields of type Date/Time called PublishFrom and PublishTo. I have 5 products in the groups selected on my Paragraph, and for each of these products I've set a date span with the published date boundaries. One of the products is left outside the range on purpose.

The product is omitted from my Product List, as expected. I then changed the direction of my Sort, and my Product List was rendered in reverse order.

Which type of Sort By are you experiencing issues with? Because I cannot reproduce this problem.

- Jeppe

 
Nuno Aguiar
Reply
Hi Jeppe,

That's weird, because I am doing the same thing and it's not working :(

I'll try and see if there's a bug or conflict somewhere with licensing or configuration, but at least the development is working.

Thanks,
Nuno

 
Nuno Aguiar
Reply
 Hi Jeppe,

Just to let you know. Everything is ok. It is a bug in the version I was testing on that I did not come across before, so I was a little confused.

Thanks a lot.

Nuno

 

You must be logged in to post in the forum