Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getSelectBox($attributeCode, $label = '', $defaultSelect = null, $extraParams = null){
- $options = array();
- $product = Mage::getModel('catalog/product');
- $attribute = $product->getResource()->getAttribute($attributeCode);
- if($attribute->usesSource()){
- $options = $attribute->getSource()->getAllOptions(false);
- array_unshift($options, array('label' => $label, 'value' => ''));
- }
- $select = Mage::app()->getLayout()->createBlock('core/html_select')
- ->setName($attributeCode)
- ->setId($attributeCode)
- ->setTitle($label)
- ->setValue($defaultSelect)
- ->setExtraParams($extraParams)
- ->setOptions($options);
- return $select->getHtml();
- }
- <?php echo Mage::helper('function')->getSelectBox('manufacturer', 'Select Manufacturer'); ?>
- <li>
- <a href="#">Browse by Manufacturer</a>
- <ul>
- <?php $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'manufacturer');
- if ($attribute->usesSource()) {
- $options = $attribute->getSource()->getAllOptions(false);
- foreach ($options as $option)
- {
- echo '<li style="list-style:none"><a href="'.Mage::getUrl('catalogsearch/advanced/result').'?manufacturer%5B%5D='.$option['value'].'">'.$option['label'].'</a></li>';
- }
- } ?>
- </ul>
- </li>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement