Friday, June 28, 2013

Magento change Multiple select to dropdown with select all option in Advanced search

How to change Multiple select to dropdown with select all option in Advanced search - Magento.


Simply change statement in ... Mage/Block/Advanced/Form.php around line 207 (Magento 1.7)
if (is_array($options) && count($options)>2)
to any number higher than the number of your attribute options:
if (is_array($options) && count($options)>10000000)
Example:
Original code:
if (is_array($options) && count($options)>2{
            $extra 
'multiple="multiple" size="4"';
            
$name.= '[]';
        
}
        
else {
            array_unshift
($options, array('value'=>'''label'=>Mage::helper('catalogsearch')->__('All')));
        
}
My code:
if (is_array($options) && count($options)>50{
            $extra 
='multiple="multiple" size="4"';
            
$name.= '[]';
        
}
        
else {
            array_unshift
($options, array('value'=>'''label'=>Mage::helper('catalogsearch')->__('Select all')));
        
}
My code, with dropdown option:
if (is_array($options) && count($options)>50{
            $extra 
= array();
            
$name.= '[]';
        
}
        
else {
            array_unshift
($options, array('value'=>'''label'=>Mage::helper('catalogsearch')->__('Select all')));
        
}

0 comments:

Post a Comment