Magento: list all values of a single attribute

Magento: list all values of a single attribute

September 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: list all values of a single attribute

Displaying All Attribute Values in Magento

You’re on the right track with your approach, but there are a few adjustments needed to make this work properly. Let’s break down the issue step by step.

Understanding the Problem

The main challenge here is that you’re trying to access an attribute collection directly from the catalog model, which isn’t designed for this purpose in Magento 1.x versions. Additionally, your URL generation and block rendering aren’t set up correctly.

Solving the Issue

Let’s start by fixing the attribute retrieval:

public function getAllArtists()
{
    $attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'artist');
    if ($attribute->usesSource()) {
        $options = $attribute->getSource()->getAllOptions(false);
        return $options;
    }
    return array();
}

This code retrieves the attribute directly from the EAV configuration. It then checks if the attribute uses a source model (which is usually the case for dropdown or multiselect attributes). If it does, we get all options using getAllOptions(false).

Rendering the Artists

Now let’s update your artist.phtml file:

<ul id="artist_list">
    <?php foreach ($this->getAllArtists() as $artist): ?>
        <li><a href="<?= $this->getUrl('catalogsearch/advanced/result', array('artist[]' => $artist['value'])) ?>"><?= $artist['label'] ?></a></li>
    <?php endforeach; ?>
</ul>

Here, we’re using the block model’s getUrl() method to generate the catalog search URL. The catalogsearch/advanced/result action is used with an array of attributes passed as parameters.

Setting Up the Static Block

Finally, make sure you have set up your static block correctly:

  1. Go to CMS > Static Blocks in your Magento admin panel.
  2. Click “Add New Block.”
  3. Set the Identifier and Title (e.g., “Artist List”).
  4. In the Content box, add {{block type="catalog/product_artist" template="catalog/product/artist.phtml"}}.
  5. Save the block.

Conclusion

With these changes, you should now see a list of artist names in your static block. Clicking on an artist will redirect to the search page with the selected attribute value passed as a filter parameter.

Remember, for more complex or custom attribute requirements, consider using Magento extensions like AMT Attributes that provide additional functionality and performance optimizations.

This solution assumes you’re working with a standard installation of Magento 1.7.0.2. If you encounter any further issues, please check your theme’s layout XML files to ensure the static block is being rendered correctly in your desired location.

Magento 1 Catalog Themes Configuration

Our network