I placed a sort order condition in my product collection . I need to sort my products in the order of

Promotional products -> quantity available

In promotional products, i need to sort based on promotion to date i.e the products with nearest expiry date should be sorted first.

I'm not getting the condition to sort the promotional products based on their promotion to date.

please help me... Thanks in advance....

2 Answers 2


if you need a more complex ORDER BY clausole you can use

$collection->getSelect()->order(new Zend_Db_Expr('IF(attribute_set_id = 9,0,1)'));

In this way you can set the ORDER BY as well as you do in the mySQL sintax.

If you need more help you should explain how you set "promotional products" and "valid date" in term of magento attribute.



try this

$order = 'DESC';
$order = 'ASC';

  • Actually my problem is not sorting based on quantity. First i need to sort promotional products. In promotional products i need to sort based on promotion valid date.so i need a condition to sort promotional products based on their nearest date for expiry.
    – user9746
    Jul 1, 2014 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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