Magento Advance Search - Drop down box of color - Option "All" not coming
I am working on a magento project where advanced search page is already built. I have one attribute called "Color" having following values and also have made attribute property Yes for advance search.
Blue Green Yellow.
I also have updated form.php of mage/...so that instead of multiselect, drop down box will come.
Now, in advance search Color drop down, I am not able to set "All" option. I want this because currently Blue is preselected and in each search, this criteria is added. I have not done any updates in other pages.
Plea开发者_C百科se help me.
Jeff
Actually this is a vary useful question and @Jeff's comment is a great solution. I report it with better formatting:
Comment out this code:
// 2 - avoid yes/no selects to be multiselects
if (is_array($options) && count($options)>2) {
$extra = 'multiple="multiple" size="4"';
$name.= '[]';
}
else {
array_unshift($options, array('value'=>'', 'label'=>Mage::helper('catalogsearch')->__('All')));
}
And replace it with this:
array_unshift($options, array('value'=>'', 'label'=>Mage::helper('catalogsearch')->__('All')));
You can easily create select box for any drop-down attributes like color, manufacturer etc and use for search form or any custom form page.
Here goes the related article:
http://www.blog.magepsycho.com/magento-utility-function-how-to-easily-create-select-box-for-drop-down-attributes
Cheers!!
精彩评论