Magento: expand „sort by“ list – „sortieren nach“ Liste erweitern

28. September 2010 at 11:20

you want to expand the default sort by list, without add new attributes? The solution:

extends the class Mage_Catalog_Model_Config and overwrite the function getAttributeUsedForSortByArray() with your own custom option array, f.e. :

class YourNamespace_Catalog_Model_Config extends Mage_Catalog_Model_Config
{
 /**
 * Retrieve Attributes Used for Sort by as array
 * key = code, value = name
 *
 * @return array
 */
 public function getAttributeUsedForSortByArray()
 {
 $custom_options = array(
 'custom_selection' => Mage::helper('catalog')->__('Custom Selection'),
 'newest_first'        => Mage::helper('catalog')->__('Newest first'),
 'bestselling'        => Mage::helper('catalog')->__('Bestselling first'),
 'promotions_first'    => Mage::helper('catalog')->__('Promotions first'),
 'price_htl'            => Mage::helper('catalog')->__('High to low'),
 'Price_lth'            => Mage::helper('catalog')->__('Low to high')
 );
 return $custom_options;
 /*
 * no further sortable attributes needed.
 *
 $options = parent::getAttributeUsedForSortByArray();
 return $custom_options + $options;
 */
 }
}
GD Star Rating
loading...
GD Star Rating
loading...
Magento: expand "sort by" list - "sortieren nach" Liste erweitern, 10.0 out of 10 based on 2 ratings
Tags: