Mateusz321 Posted August 23, 2022 Share Posted August 23, 2022 In all categories products are sorted according to the default filter Sort by: New products first, I would like to know if it's possible to set some categories sorting on the position ''Random''? For example, the category: home, cars, pets should be set to ''New products first'' while the category flowers on ''Random''. Thank you Link to comment Share on other sites More sharing options...
Mateusz321 Posted August 24, 2022 Author Share Posted August 24, 2022 I guessed so too, can you please advise which file should be modified, I'm not an expert yet... Thank you Link to comment Share on other sites More sharing options...
Knowband Plugins Posted August 24, 2022 Share Posted August 24, 2022 in classes/controller/ProductListingFrontController.php file, getProductSearchVariables() is used to return the product listing for category page. Replace if (($encodedSortOrder = Tools::getValue('order'))) { $query->setSortOrder(SortOrder::newFromString( $encodedSortOrder )); } with if (($encodedSortOrder = Tools::getValue('order'))) { $query->setSortOrder(SortOrder::newFromString( $encodedSortOrder )); } else { $query->setSortOrder(SortOrder::newFromString( ["Your sorting method"] )); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now