So I am trying to create a dropdown on my homepage that will allow the user to select a brand and it will bring them to a page with each product that has that attribute selected.

So I took a post (http://www.blog.magepsycho.com/magento-utility-function-how-to-easily-create-select-box-for-drop-down-attributes/) and made a few changes to how it is called since it was throwing a fatal error.

function getSelectBox($attributeCode, $label = '', $defaultSelect = null, $extraParams = null){
    $options            = array();
    $product            = Mage::getModel('catalog/product');
    $attribute          = $product->getResource()->getAttribute($attributeCode);
        $options = $attribute->getSource()->getAllOptions(false);
        array_unshift($options, array('label' => $label, 'value' => ''));

    $select = Mage::app()->getLayout()->createBlock('core/html_select')
    return $select->getHtml();

This is the code that is calling the attributes inside of a dropdown.

The code I used to call it was:

<?php echo Mage::helper('function')->getSelectBox('manufacturer', 'Select Manufacturer'); ?>

This worked and called all the manufacturers for me however the issue is that if I select one of the manufacturers in the dropdown it does not bring me to another page with the products.

Each product in my store is assigned a manufacturer. Each manufacturer is listed in the dropdown. I just want it so when I click on one of the manufacturer options that it will bring me to a list of those products that have said manufacturer assigned.

I do not want an extension for this at all. Please refrain from suggesting them.

I do realize I can create categories for each of the brands as well however I am unsure if that would be the smartest way to do this.

Thank you! I would really appreciate any help here. :)


Based on this answer, using option #1, modified to work on Magento CE 1.9+:

 <a href="#">Browse by Manufacturer</a>
<?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>';
} ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.