diff --git a/src/Libraries/Nop.Core/Domain/Catalog/ProductSortingEnum.cs b/src/Libraries/Nop.Core/Domain/Catalog/ProductSortingEnum.cs
index ae7927a756b..0c0ab02a6f5 100644
--- a/src/Libraries/Nop.Core/Domain/Catalog/ProductSortingEnum.cs
+++ b/src/Libraries/Nop.Core/Domain/Catalog/ProductSortingEnum.cs
@@ -34,4 +34,9 @@ public enum ProductSortingEnum
/// Product creation date
///
CreatedOn = 15,
+
+ ///
+ /// Product in stock
+ ///
+ InStock = 16,
}
\ No newline at end of file
diff --git a/src/Libraries/Nop.Services/Catalog/ProductExtensions.cs b/src/Libraries/Nop.Services/Catalog/ProductExtensions.cs
index 14457df99b2..8546156c1b7 100644
--- a/src/Libraries/Nop.Services/Catalog/ProductExtensions.cs
+++ b/src/Libraries/Nop.Services/Catalog/ProductExtensions.cs
@@ -65,6 +65,9 @@ orderby item.sortName descending
ProductSortingEnum.PriceDesc => productsQuery.OrderByDescending(p => p.Price),
ProductSortingEnum.CreatedOn => productsQuery.OrderByDescending(p => p.CreatedOnUtc),
ProductSortingEnum.Position when productsQuery is IOrderedQueryable => productsQuery,
+ ProductSortingEnum.InStock => productsQuery
+ .OrderByDescending(p => p.StockQuantity > 0)
+ .ThenByDescending(p => p.UpdatedOnUtc),
_ => productsQuery.OrderBy(p => p.DisplayOrder).ThenBy(p => p.Id)
};
}
diff --git a/src/Presentation/Nop.Web/Views/Catalog/_CatalogSelectors.cshtml b/src/Presentation/Nop.Web/Views/Catalog/_CatalogSelectors.cshtml
index 1d7d4818f49..a92ed4bbb59 100644
--- a/src/Presentation/Nop.Web/Views/Catalog/_CatalogSelectors.cshtml
+++ b/src/Presentation/Nop.Web/Views/Catalog/_CatalogSelectors.cshtml
@@ -53,7 +53,7 @@