Joachim Tranberg Posted August 25, 2010 Share Posted August 25, 2010 Hey Guys. How are you?I am finishing my new template, but i have a few things that i cant figure out how to change.Best-sales.php: are currently showing ALL sold products, how do i limit it to 36 products?I also need to sort it after how many sold, not just random. Most sold first.New-products.php:How do i modify so it is showing the latest product FIRST!?Product-list:How do i force this to show products A-Z ?Please note that i have removed the "Sort after" drop-down menu in my Presta Theme.I would appreciate your help, thanksBest RegardsJoachim Link to comment Share on other sites More sharing options...
rocky Posted August 25, 2010 Share Posted August 25, 2010 Try going to the Preferences > Products tab and changing "Default order by" to "Position in category" and "Default order way" to "Decreasing". The reason I say this is that on the best sellers page, "Position in category" is converted to "Number of sales" and on the new products page, "Position in category" is converted to "Date added", so after making this change, your best sellers should be sorted from highest sales to lowest sales and your new products page from newest date to oldest date.The only problem then is that the product listings will be sorted by the position you specify on the Catalog tab. I can't see any way to automatically sort them by name without modifying PrestaShop's code. You'll need to change line 60 of category.php (in PrestaShop v1.3.1) from: $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay); to: $orderBy = 'name'; $orderWay = 'ASC'; $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay); and if you want search results sorted by name too, you'll need to change line 22 of search.php (in PrestaShop v1.3.1) from: $search = Search::find(intval($cookie->id_lang), $query, $p, $n, $orderBy, $orderWay); to: $orderBy = 'name'; $orderWay = 'ASC'; $search = Search::find(intval($cookie->id_lang), $query, $p, $n, $orderBy, $orderWay); This will override the default 'position' and 'DESC' with 'name' and 'ASC' just for the product and search listings. Link to comment Share on other sites More sharing options...
Joachim Tranberg Posted August 27, 2010 Author Share Posted August 27, 2010 Thanks Rocky, your my hero However a part of my question wasn't anwered. Best-sales.php:are currently showing ALL sold products, how do i limit it to 36 products?I also need to sort it after how many sold, not just random. Most sold first. Looking forward to a reply Link to comment Share on other sites More sharing options...
rocky Posted August 27, 2010 Share Posted August 27, 2010 I forgot about that part. To fix that, change line 7 of best-sales.php from: $nbProducts = intval(ProductSale::getNbSales()); to: $nbProducts = intval(ProductSale::getNbSales()); if ($nbProducts > 36) $nbProducts = 36; and change line 10 from: $products = ProductSale::getBestSales(intval($cookie->id_lang), intval($p) - 1, intval($n), $orderBy, $orderWay); to: $products = ProductSale::getBestSales(intval($cookie->id_lang), /*intval($p) - */1, /*intval($n)*/ 36, $orderBy, $orderWay); After making this change, whenever you go to best-sales.php, you will get a single page with 36 products. Link to comment Share on other sites More sharing options...
Joachim Tranberg Posted August 27, 2010 Author Share Posted August 27, 2010 Perfect.Works great. Link to comment Share on other sites More sharing options...
rocky Posted August 27, 2010 Share Posted August 27, 2010 If your issue is resolved, please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
Christian Alias Posted June 2, 2016 Share Posted June 2, 2016 Anybody knows how to do this in 1.6 because there is no best-sales.php thanks! 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