logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
jeffr_ca  
#1 Posted : Wednesday, August 26, 2020 9:23:27 AM(UTC)
jeffr_ca

Rank: Advanced Member

Groups: Authorized User, Developers, Registered, HelpDesk
Joined: 1/7/2019(UTC)
Posts: 112

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
I would like to use the Featured Category Grid Widget to display a selection of Categories, but in a static order.

Is it possible for us to change the behaviour of this widget to NOT Random Sort the displayed categories on each page load? We would like the categories to be shown in the same order at all times, using the order that they are created in the Admin side.

Thanks!

-Jeff

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

shari  
#2 Posted : Thursday, August 27, 2020 6:54:04 AM(UTC)
shaharyar

Rank: Advanced Member

Groups: Admin, Developers, Registered, HelpDesk, Authorized User
Joined: 10/5/2018(UTC)
Posts: 704

Thanks: 5 times
Was thanked: 113 time(s) in 112 post(s)
You have to make changes in controller to achieve the requirements.

Please follow the steps:

1- Open category controller file \Website\Controllers\CategoryController.cs
2- Search for the code

Code:
var categories = _categoryRepo.GetRandomFeaturedCategories(parameters.PublicOnly, parameters.Size)
                .Select(category => new CategoryModel()
                {
                    Id = category.Id,
                    Name = category.Name,
                    NavigateUrl = category.NavigateUrl,
                    ThumbnailUrl = category.ThumbnailUrl,
                    ThumbnailAltText = category.ThumbnailAltText,
                    Summary = category.Summary,
                }).ToList();

3- Replace it with


Code:
var categories = _categoryRepo.GetFeaturedCategories(parameters.PublicOnly, maximumRows: parameters.Size)
                .Select(category => new CategoryModel()
                {
                    Id = category.Id,
                    Name = category.Name,
                    NavigateUrl = category.NavigateUrl,
                    ThumbnailUrl = category.ThumbnailUrl,
                    ThumbnailAltText = category.ThumbnailAltText,
                    Summary = category.Summary,
                }).ToList();


4- Compile the project

This is a server side change so you must use the code after compilation.
jeffr_ca  
#3 Posted : Thursday, August 27, 2020 9:03:25 AM(UTC)
jeffr_ca

Rank: Advanced Member

Groups: Authorized User, Developers, Registered, HelpDesk
Joined: 1/7/2019(UTC)
Posts: 112

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Thank you Shari!

-Jeff
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.