0

I created an attribute sorting order (attribute code : shortorder ) for arrange/sorting(ASC or DESC) the products by adding value to this attribute while adding the products.

In the list.phtml product collections are collect by

$_productCollection=$this->getLoadedProductCollection();.

Is there any way to do this shorting in product view page?

1 Answer 1

1

You might have to override the Mage_Catalog_Block_Product_List block, specifically, its function _getProductCollection() to implement the necessary filtering.

A proposed override for the function Mage_Catalog_Block_Product_List::_getProductCollection:

protected function _getProductCollection()
{ 
    $collection = parent::_getProductCollection();
    $collection->addAttributeToSort('attribute code', 'asc');
    $this->_productCollection = $collection;

    return $this->_productCollection;
}
4
  • Thanks @liyakath. i am using getLoadedProductCollection() function.
    – Mujahidh
    Commented Feb 16, 2015 at 12:13
  • thats not concern,it is ok this function is called after my above function you can see Mage_Catalog_Block_Product_List
    – liyakat
    Commented Feb 16, 2015 at 12:19
  • $liyakath am confused to where i want add this?
    – Mujahidh
    Commented Feb 16, 2015 at 13:27
  • refer this magento.stackexchange.com/questions/10748/…
    – liyakat
    Commented Feb 17, 2015 at 4:16

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.