Product Sort Options

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
Will someone please direct me to the source code file (3.60) for editing the product sort options list?

I want to remove "position" and "created on" and re-order the other options so it is "high to low" - "low to high" - "A to Z" - "Z to A".

Similar to the post here, https://www.nopcommerce.com/boards/t/31049/allow-store-owner-to-decide-the-product-sorting-options-available-per-category.aspx, but for 3.6 the filepath is a bit different.
8 years ago
The easiest way to hide some sort options is to edit 'PrepareSortingOptions' method in the 'CatalogContoller'.
Add after
foreach (ProductSortingEnum enumValue in Enum.GetValues(typeof(ProductSortingEnum))) {

the following string:
if(enumValue == ProductSortingEnum.Position || enumValue == ProductSortingEnum.CreatedOn) continue;

You can re-order it in the same method.
8 years ago
Could you give me a filepath for "PrepareSortingOptions"? I don't see it in the catalog controller (I am using 3.60). The only file I have found which has anything related to sorting is nop\views\catalog\_CatalogSelectors. It has the following code:

@*sorting*@
    @if (Model.AllowProductSorting)
    {
        <div class="product-sorting">
            <span>@T("Catalog.OrderBy")</span>
            @Html.DropDownList("products-orderby", Model.AvailableSortOptions, new { onchange = "setLocation(this.value);" })
        </div>
8 years ago
Nop.Web\Controllers\CatalogController.cs -> PrepareSortingOptions method
8 years ago
Go to ProductSortingEnum.cs file. Which is Nop.core/Domain/Catalog
Edit your enum. As you want.
8 years ago
I am not editing this in Visual Studio. I am editing the files using notepad++ directly on the server.

My site, Nop, has the following folders; Administration, App_Data, Bin, Content, Plugins, Scripts, Themes, Views, and contains the ErrorPage, favicon, FileNotFound, Global, license, and Web files.

Searching for the file, returns no results. Is there any reason why that file is not accessible?
8 years ago
Actually you are using no source file. thats why you dont find this file.
8 years ago
Thank you Anik!
7 years ago
Excuse me, I still do not understand how to configure the default sort to "PriceAsc". You can clear my head perhaps including changes to the code.

thank you

Marco
7 years ago
Hi.
What version of nopCommerce do you use?
In the 3.80 you don't need to change the code, go to the catalog settings and configure an order of sorting options by changing display order.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.