Sorting Featured Products Grid

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
dustinmeyer
Ensign (ENS)
Ensign (ENS)
Posts: 2
Joined: Mon Apr 23, 2012 10:21 am

Sorting Featured Products Grid

Post by dustinmeyer » Mon Apr 23, 2012 10:53 am

I have implemented a customized version of the featured products grid. Everything is working properly, but now I'd like to order the products in the grid so that certain products are always listed first. I changed the following line from

Code: Select all

ProductCollection products = ProductDataSource.GetRandomFeaturedProducts(0, true, IncludeOutOfStockItems, this.Size);
to

Code: Select all

ProductCollection products = ProductDataSource.GetFeaturedProducts(0, true, IncludeOutOfStockItems, "");
I figured out that I can pass "Name" as the last parameter in the "GetFeaturedProducts" method and the products would then be ordered by their names. However, I'd like to order the products by the "OrderBy" field that is updated when re-ordering products in the admin. Is there a way to accomplish this?

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Sorting Featured Products Grid

Post by david-ebt » Mon Apr 23, 2012 1:49 pm

In your code you're actually using two different GetFeaturedProducts methods. The first method is taking these parameters:

Code: Select all

int categoryId, bool publicOnly, int maximumRows, int startRowIndex
and the second method is taking these parameters:

Code: Select all

int categoryId, bool publicOnly, bool includeOutOfStockItems, string sortExpression
However, I don't think OrderBy is a valid field for the GetFeaturedProducts method. You can try it by changing the "" to "OrderBy". The GetFeaturedProducts context, it's just based on whether the IsFeatured flag is set.

Another option is to create a new category where you put your featured products. Then you can use the CatalogNodeDataSource and get your products out in OrderBy order.
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

dustinmeyer
Ensign (ENS)
Ensign (ENS)
Posts: 2
Joined: Mon Apr 23, 2012 10:21 am

Re: Sorting Featured Products Grid

Post by dustinmeyer » Mon Apr 30, 2012 11:53 am

David, thank you for your help. We've decided to add a "Featured Products" category, per your suggestion and pull all items for that category to display in the featured products grid.

Post Reply