Jump to content

[SOLVED] Products On Special (Prices Drop) Page: Sort by Date Added?


artofadornment

Recommended Posts

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 by artofadornment (see edit history)
Link to comment
Share on other sites

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

  • 2 weeks later...

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 by artofadornment (see edit history)
Link to comment
Share on other sites

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 by artofadornment (see edit history)
Link to comment
Share on other sites

  • 9 months later...

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:
* 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 by ps3z (see edit history)
Link to comment
Share on other sites

  • 4 years later...
  • 2 years later...
  • 3 weeks later...

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

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...