0

I want to sort Magento product collection with multiple attributes at catalog product list page. I am using this code

$this->_collection->setOrder('price', 'desc');
$this->_collection->setOrder('price_plus_shipping', 'desc');

I also tried this code as well

$this->_collection->setOrder(array('price', 'price_plus_shipping'),Varien_Data_Collection::SORT_ORDER_DESC);

When i sort these both combine its not giving me accurate results but if i use both separately like when i am using only

price_plus_shipping

its working fine also as

price

its also working file they are showing me accurate results. But i want to use them combine. in Price i have product prices in price_plus_shipping i have alphabets like

a,b,c etc

3

Try this :

$this->_collection->setOrder([$field1, $field2, ...], 'DESC');

OR Try this :

$this->_collection->setOrder('price', 'desc');
$this->_collection->getSelect()->order('price_plus_shipping desc');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.