0

In product listing page I need to rearrange product listing price.

$_productCollection = Mage::getModel('catalog/product')->getCollection()
            ->addAttributeToSort('price', 'ASC')
            ->load();

I tried above code in list.phtml page it's working in initial list.

Not working in ajax scroll

4
  • 1
    Well, I'm guessing your ajax call calls a controller, did you change it in your controller too? Commented Mar 29, 2016 at 11:38
  • You want add price filter ??
    – Arunendra
    Commented Mar 29, 2016 at 11:42
  • @Arunendra yes i need price sorting Commented Mar 29, 2016 at 11:50
  • @JulienLachal I don't know where i need to change controller Commented Mar 29, 2016 at 11:51

1 Answer 1

0

You need to override _getProductCollection() function.

Or copy List.php from core location

app/code/Mage/Catalog/Block/Product/

And paste in local codePool

app/code/local/Mage/Catalog/Block/Product/List.php

And add your new filter just before this line

$this->prepareSortableFieldsByCategory($layer->getCurrentCategory());

your code will be like:

$this->_productCollection = $layer->getProductCollection()->addFieldToFilter('price','ASC');  

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.