artofadornment Posted December 17, 2013 Share Posted December 17, 2013 (edited) By default, I have my shop set up to sort products by date added (newest products first). However for some unknown reason, the Products On Sale page (prices-drop.tpl?) sorts products by price (highest first). Is there a way I can change the default sort order to newest first? Here's a link to my store's specials page: http://www.artofadornment.ca/on-sale Thanks in advance for your help! ~ Elaine Edited October 27, 2014 by artofadornment (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted December 17, 2013 Share Posted December 17, 2013 what ps version you use? it looks like 1.4, am I right? Link to comment Share on other sites More sharing options...
artofadornment Posted December 17, 2013 Author Share Posted December 17, 2013 Oops, sorry - I should have mentioned, I'm using version 1.5.3.1. Link to comment Share on other sites More sharing options...
vekia Posted December 17, 2013 Share Posted December 17, 2013 try with modification of PricesDropController.php (located in controllers/front directory) there is a code: 'products' => Product::getPricesDrop($this->context->language->id, (int)$this->p - 1, (int)$this->n, false, $this->orderBy, $this->orderWay), change it to: 'products' => Product::getPricesDrop($this->context->language->id, (int)$this->p - 1, (int)$this->n, false, "date_add", $this->orderWay), Link to comment Share on other sites More sharing options...
artofadornment Posted December 18, 2013 Author Share Posted December 18, 2013 That worked great, thank you!! Link to comment Share on other sites More sharing options...
vekia Posted December 18, 2013 Share Posted December 18, 2013 you're welcome thank you for confirmation that it works i marked my answer as a solution with regards, Milos Link to comment Share on other sites More sharing options...
artofadornment Posted December 27, 2013 Author Share Posted December 27, 2013 (edited) Milos - I just noticed a strange thing. I used your solution and changed the code and everything looked great (sale products displayed newest first). But today I discounted a few more products, and the newly discounted ones are appearing after all the other sale products, with the product I just finished discounting appearing totally last. The dates these products were originally created on are newer than most of the other products, so I don't think that's why they are displaying last. So should there be a "desc" is the code somewhere? I'm not sure what to do to fix that. Thanks again for all your help! EDIT: I just discounted another product (originally created more recently than all the others) and it is displaying as the very first item, as it should. The weird thing is, the item that is currently displayed as absolute last was only discounted yesterday, and its original creation date was only a few weeks before the product I discounted just now. They should both appear on the first page of results however only one of them does... O_o Edited December 27, 2013 by artofadornment (see edit history) Link to comment Share on other sites More sharing options...
artofadornment Posted December 28, 2013 Author Share Posted December 28, 2013 (edited) I'm changing the status from "solved" to unsolved because in addition to the new problem I wrote about above, I have discovered another conflict (sorry about this!). If the customer uses the drop-down list to change the sorting to something else (for example "product name A to Z") the sorting doesn't work properly, the products don't get sorted by name. The sorting changes to something else but I have no idea what criteria it's using, it seems to almost be random. PS version 1.5.3.1, here is the page again: http://www.artofadornment.ca/on-sale :/ Edited December 28, 2013 by artofadornment (see edit history) Link to comment Share on other sites More sharing options...
artofadornment Posted October 27, 2014 Author Share Posted October 27, 2014 OK, I finally got back to this, and figured out that my problem could be solved by using "date_upd" (when the product was last updated) instead of "date_add". Marking "solved" again. Link to comment Share on other sites More sharing options...
ps3z Posted November 3, 2014 Share Posted November 3, 2014 (edited) Hi guys how do i set the sorting as date updated for price drop products page? i set like this but page is being blank. presta ver: 1.5.0.8 <?php /* * 2007-2014 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class PricesDropControllerCore extends FrontController { public $php_self = 'prices-drop'; public function setMedia() { parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'product_list.css'); } /** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->productSort(); $nbProducts = Product::getPricesDrop($this->context->language->id, null, null, true); $this->pagination($nbProducts); $products = Product::getPricesDrop($this->context->language->id, (int)$this->p - 1, (int)$this->n, false, $this-> "date_upd", $this->orderWay); $this->addColorsToProductList($products); $this->context->smarty->assign(array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM') )); $this->setTemplate(_PS_THEME_DIR_.'prices-drop.tpl'); } } Regards Ps3z Edited November 3, 2014 by ps3z (see edit history) Link to comment Share on other sites More sharing options...
Vins0n254 Posted October 22, 2019 Share Posted October 22, 2019 How about in Prestashop 1.7? Link to comment Share on other sites More sharing options...
ukbaz Posted August 3, 2022 Share Posted August 3, 2022 Doesn't work in Prestashop 1.6 :( Link to comment Share on other sites More sharing options...
MahyarK Posted August 25, 2022 Share Posted August 25, 2022 in 1.7.8.7 i just added to the getProducSearchQuery() instead of name ascending -> date_upd descending (for last updated products or date_add for last added products) protected function getProductSearchQuery() { $query = new ProductSearchQuery(); $query ->setQueryType('prices-drop') ->setSortOrder(new SortOrder('product', 'date_upd', 'desc')); return $query; } Link to comment Share on other sites More sharing options...
Micros Posted September 6, 2023 Share Posted September 6, 2023 @MahyarK thats worked for u? i need same solution to orderby default for "date added" on default page of "prices-drop" thx 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