Developer forum

Forum » Development » Custom Related Products Loop

Custom Related Products Loop

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

Wasn't there a code example of how to generate a loop of related products?

 

I have a SQL query that will essentially return a list of ProductIDs that I would like to then put in a loop. I know there are a ton of ways to do this, but I want to avoid doing it in the template, and before I develop a method, if there's something I'd subscribe to, I'd like to do that instead.

 

Best Regards,

Nuno Aguiar


Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
This post has been marked as an answer

Hi Nuno,

Do you mean RelatedProductListProvider?

using Dynamicweb.Ecommerce.Extensibility.Provider;

[RelatedProductList("MyRelatedProductList")] // Used as template loop name
public class MyRelatedProductListProvider : RelatedProductListProvider
{
    public override ProductCollection GetCollection(RelatedProductListProviderEventArgs eventArgs)
    {
        return null; // TODO: Return products here
    }
}

/Morten

Votes for this answer: 1
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Morten,

 

Perfect that's just what I was looking for and could not find it. Did not remember to look at Providers.

 

Thanks for being able to read between my innacurate message.

 

Best Regards,

Nuno Aguiar

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi again Morten,

 

This all works as expected, but I see ProductCollection to be obsolete, but there's no suggested alternative.

 

I know there are some premature objects and methods around in the code flaged as obsolete, and I am wondering if this one of thore OR if there is there a better alternative?

 

Best Regards,

Nuno Aguiar

 
Nicolai Pedersen
Reply

No, just use product collection.

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Got it, thanks

 

You must be logged in to post in the forum