Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. function getSelectBox($attributeCode, $label = '', $defaultSelect = null, $extraParams = null){
  2. $options = array();
  3. $product = Mage::getModel('catalog/product');
  4. $attribute = $product->getResource()->getAttribute($attributeCode);
  5. if($attribute->usesSource()){
  6. $options = $attribute->getSource()->getAllOptions(false);
  7. array_unshift($options, array('label' => $label, 'value' => ''));
  8. }
  9.  
  10. $select = Mage::app()->getLayout()->createBlock('core/html_select')
  11. ->setName($attributeCode)
  12. ->setId($attributeCode)
  13. ->setTitle($label)
  14. ->setValue($defaultSelect)
  15. ->setExtraParams($extraParams)
  16. ->setOptions($options);
  17. return $select->getHtml();
  18. }
  19.  
  20. <?php echo Mage::helper('function')->getSelectBox('manufacturer', 'Select Manufacturer'); ?>
  21.  
  22. <li>
  23. <a href="#">Browse by Manufacturer</a>
  24. <ul>
  25. <?php $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'manufacturer');
  26. if ($attribute->usesSource()) {
  27. $options = $attribute->getSource()->getAllOptions(false);
  28. foreach ($options as $option)
  29. {
  30. echo '<li style="list-style:none"><a href="'.Mage::getUrl('catalogsearch/advanced/result').'?manufacturer%5B%5D='.$option['value'].'">'.$option['label'].'</a></li>';
  31. }
  32. } ?>
  33. </ul>
  34. </li>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement