Magento - Change attribute select to dropdown list in Adv Search

Magento - Change attribute select to dropdown list in Adv Search

August 23, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - Change attribute select to dropdown list in Adv Search

Changing an Attribute Select to a Dropdown List in Magento Advanced Search

Changing an attribute select block into a dropdown list can enhance the user experience by making your advanced search more intuitive and visually appealing. The default Magento configuration presents attributes as bulleted lists, which may not be optimal for all use cases.

In this post, I’ll guide you through the process of converting an attribute select into a dropdown menu using a simple PHP tweak in your template file.

Understanding the Problem

When using the default Magento advanced search layout, certain attribute types like ‘select’ or ‘multiselect’ are rendered as block lists by default. For example:

<div class="input-box">
    <?php echo $this->getAttributeSelectElement($_attribute) ?>
</div>

This code snippet generates an unordered list (<ul>) containing the attribute options, which is not ideal for a clean and modern UI.

Solution: Converting to a Dropdown Menu

To transform this select block into a dropdown menu, we need to modify how Magento renders the attribute element. Here’s how you can achieve this:

  1. Find your template file: Navigate to the directory containing your current advanced search layout in Magento 2. Typically, it would be located at app/design/frontend/[Vendor]/[Theme]/Magento_AdvancedSearch/templates/form.phtml.

  2. Identify the relevant section: Look for the part of the code where attribute select blocks are rendered. It usually contains a <?php echo $this->getAttributeSelectElement($_attribute) ?> line within an <li> element.

  3. Replace with a dropdown: Instead of using $this->getAttributeSelectElement(), we’ll create a new dropdown menu manually and populate it with the attribute options. Here’s how:

<div class="input-box">
    <select name="<?php echo $_attribute->getName() ?>" id="<?php echo $_attribute->getFacetedData('label') ?>" data-placeholder="<?php echo __($_attribute->getLabel()) ?>" class="custom-dropdown">
        <?php foreach ($_attribute->getOptions() as $option): ?>
            <option value="<?php echo $option['value'] ?>"<?php if ($this->data['attributes'][$_attribute->getName()] == $option['value']) echo ' selected="selected"' ?>>
                <?php echo __($option['label']) ?>
            </option>
        <?php endforeach; ?>
    </select>
</div>

In this code, we’re creating a new <select> element and populating it with the available attribute options in a loop. We also set the appropriate attributes like name and id, as well as add a placeholder for accessibility.

Conclusion

Changing an attribute select into a dropdown list improves the visual appeal and usability of your Magento advanced search. By making this small modification to your template file, you can provide a more intuitive interface for your customers while keeping the codebase clean and maintainable.

Remember, always backup your files before editing them directly in the core theme. If you’re using an external theme, consider creating a child theme to apply these changes without losing updates from the original theme.

For further reference on Magento template customization best practices, I recommend checking out our guide at Laravel Company for more insights.

Magento 2 Themes Configuration Orders

Our network