sort by price is not working in magento 1.9

my site has just configurable products only . when i checked code it was using below code to load products


so i though of temporary fix (below code) , but that code work fine for just single page , issue is still there when user navigates to next page. so i need way to fix this bug . Does any one have idea page where getLoadedProductCollection is defined . So i can add sort there to fix issue

foreach($_productCollection as $mprod){
    $obj = Mage::getModel('catalog/product');
    $product = $obj->load($products->getData('default_configuration_id')); echo " ";
    $mysortprice[(int)$product->getPrice()] =  $mprod;
$sortorder = (string)$this->getRequest()->getParam('dir');
$sorttype = (string)$this->getRequest()->getParam('order');

if($sortorder=='asc' && $sorttype=='price'){
}else if($sortorder=='desc' && $sorttype=='price'){

1 Answer 1


1) Sorting by price should work perfectly for any kind of products if you have Price Attribute chosed if Available Sort Options (on Category edit page) and if you have Price Index built well.

Just try to add "?dir=desc&order=price" to your category url and see if it will change sorting

2) But if you would like to apply your custom sorting anyway - you can use Observer method, which is described here

3) But, call for "loadByAttribute" for all products in the collection is very heavy. Instead of it you need to use next code:

$products = $observer->getCollection();
    ->order('price_index.final_price', 'asc');
  • i am using configurable products and magento's default sort by price seems not fine i had done indexing and all
    – gaurav
    Commented Aug 29, 2016 at 14:56
  • You can also check "Admin - Catalog - Edit Attributes - Price" attribute. Use for sorting option should be enabled like here monosnap.com/file/4c0vkoKohTmtlvEq8AbqrbwLSVDb3i#
    – Neklo.com
    Commented Aug 30, 2016 at 8:03
  • But anyway - Price sorting should work by default. Maybe some third party extension blocking or broke this sorting. If you can share an access to admin panel - I can review it more detailed
    – Neklo.com
    Commented Aug 30, 2016 at 8:28
  • can i have ur email or skype
    – gaurav
    Commented Aug 30, 2016 at 9:55
  • pinged u on skype check if u can help
    – gaurav
    Commented Sep 1, 2016 at 10:50

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.