I am trying to list all existing values of a newly created attribute in magento 1.7.0.2. (and make them clickable links, so when they are clicked they list all the elements with a specific attribute value, but this is not a priority right now)
Attribute Code - "Artist"
So far I have created the Artist.php file in the application / code / core / Mage / Catalog / Block / with the following code:
public function getAllArtists()
{
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'artist');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$artists = $attribute->getSource()->getAllOptions(false);
return $artists;
}
and the artist.phtml file in / app / design / frontend / default / template -name / template / catalog / product with this code:
<ul id="artist_list">
<?php foreach ($this->getAllArtists() as $artist): ?>
<li><a href="<?php Mage::getURL() ?>catalogsearch/advanced/result/?&artist;[]=<?php echo $artist['value'] ?>&search;="><?php echo $artist['label'] ?></a></li>
<?php endforeach; ?>
</ul>
which is then called in a static block with
{{block type="core/template" template="catalog/product/artist.phtml"}}
but nothing appears ...
I used the code from this thread: http://www.magentocommerce.com/boards/viewthread/19982/P0/
" ",
.. /template/product/view.phtml
<?php echo $_product->getData('artist') ?>
.
?