Is there a way in the product search sorting list to order the products by highest price to lowest price but then have products with zero price displayed at the end.
The normal sorting works fine (low to high or high to low) but would really like the ability to include the zero price products at the end, an example of how it would be listed would be:
Product 1: £3
Product 2: £18
Product 3: £0
Product 4: £0
I haven't found a way from searching here or Google yet and not being too familiar with Magento I am not sure where I would look to change this. If anyone has an answer or can point me to the query or correct file for me to edit myself I don't mind having a go myself.
Using some help from here and other questions I have edited the _getProductCollection()
method inside the file /app/code/core/Mage/Catalog/Block/Product/List.php
(don't worry I've copied to local) and added these few lines:
$orderFilterType = $this->getRequest()->getParam('order');
$dirFilterType = $this->getRequest()->getParam('dir');
if( isset( $orderFilterType ) && $orderFilterType == 'price' && isset( $dirFilterType ) && $dirFilterType == 'asc' ) {
$this->_productCollection = $layer->getProductCollection()->addAttributeToSort( 'price', 'DESC' );
} else {
$this->_productCollection = $layer->getProductCollection();
}
This means that whatever I do inside this code will only run once someone has selected the orderby price dropdown with the ascending option.
The problem is now is I'm not sure what to do to affect the value for $this->_productCollection = $layer->getProductCollection();
to make this return as I want.