I want to do a sort using getLoadedProductCollection.
For the product attribute, I have one custom attribute 'featured_product'
Here is my code:
$sort=$_GET['s'];
$_productCollection=$this->getLoadedProductCollection()->addAttributeToSelect('featured_product');
$_productCollection->clear();
$_productCollection->getSelect()->reset(Zend_Db_Select::ORDER);
switch($sort)
{
case 'lp':
$_productCollection->addAttributeToSort('price', 'ASC');
break;
case 'hp':
$_productCollection->addAttributeToSort('price', 'DESC');
break;
case 'fp':
$_productCollection->addAttributeToSort('featured_product');
break;
}
For the first 2 cases it works without problems.
But the third one does not work at all.
I want to move all selected products to the top of the collection list.
How can I change the code to achieve the third case?
thanks
source
share