Developer forum

Forum » Development » Sort products programatically

Sort products programatically


Reply
Hi I posted a similar thread about six months ago: http://engage.dynamicweb-cms.com/Forum-5.aspx?PID=34&action=ShowThread&ThreadID=1745.

Issue is that I would like to sort products which I write to XML from a custom module, but when I sort the products in the backend the corresponding order in the frontend doesnt match.

heres how I load the products: 

Group group = new Group(Properties.get_Value("group"));

//Here I would like to do the sorting...

foreach (Product product in group.Products)
{
   XmlElement productNode = productXML.CreateElement("Product");
    ...etc
}

How can this be done?

best regards Sune Fengel
 

Replies

 
Reply
Isn't that a matter of calling Sort on the Products collection?


group.Products.Sort(ProductCollection.SortBy.Name, ProductCollection.SortDirection.Descending);

Hope this helps,

Imar


 
Reply
Yeah that can be done, but it would give me an alphabetical sortorder (right?), and what I would like to do is get the sortorder as the customer views it in the ecom interface.

- Sune
 
Reply
Doesn't using ProductCollection.SortBy.UserDefined as the sort type do the trick?

Imar
 
Reply
Yes that did the trick.

Thanks a bunch.

- Sune

 

You must be logged in to post in the forum