Jump to content
artofadornment

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

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)

Share this post


Link to post
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),

Share this post


Link to post
Share on other sites

you're welcome :) thank you for confirmation that it works

i marked my answer as a solution

 

with regards,

Milos

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 license@prestashop.com 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 <contact@prestashop.com>
*  @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)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More