Can you please tell me how can Sort products thats are only "IN STOCK" by custom option on products listing page...

as for the lowest and highest price i am using this code...

 <option value="<?php echo $this->getOrderUrl('price', 'asc') ?>" <?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>>Lowest Price</option>
<option value="<?php echo $this->getOrderUrl('price', 'desc') ?>" <?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'desc'): ?> selected="selected" <?php endif; ?>>Highest Price</option>

What code changes should i do to show only products that are in stock by sort by option...

Should i have to create a custom attribute first or there will be any attribute already in the adminpanel...

If yes, what will be the attribute code.. please help me i need it on urgent basis.

Thanks in advance,,,

2 Answers 2


To add a new custom sorting option, you need to

1) rewrite class Mage_Catalog_Model_Config and update method getAttributesUsedForSortBy

2) check if you new method is selected and update the product collection according to new option logic.

For example, this module rewrites the Mage_Catalog_Block_Product_List_Toolbar and modifies setCollection method.


Try looking at this post https://stackoverflow.com/questions/5301841/filtering-product-collection-on-is-salable

More search results: http://goo.gl/TckAcm

  • I want to show an option in dropdown buddy.. is there any way... ?? Commented Oct 20, 2014 at 10:07
  • This is a very low quality answer. Please add some description or code snippets..
    – Dexter
    Commented Oct 20, 2014 at 11:02

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.