Posts Tagged ‘ Magento Attribute ’

Serching Product by Attribute from Product page.

Sometimes people to want to  display product attribute in product page. then they want to link this attribute. if someone click on that link then all product of that attribute will display as a search result. for example a movie disc selling site. or a book shop. has many artist list or actor list.  then you can easily filter them by attribute artist and actor. and this code will help you.


<?php
$catingArtist = $_product->getArtist();

?>
<?php if(!empty($catingArtist)) {
$catingArtistArr = explode(',',$catingArtist);
$tagUrl = $this->getUrl('catalogsearch/advanced/result');
$tagUrl .='?artist=';
?>

<?php if(count($catingArtistArr)>0) : ?>
<span style="padding:0px 2px 0px 2px;"><?php  echo $this->__('Cast:-') ?></span>
<?php foreach($catingArtistArr as $val) : ?>
<a href="<?php echo $tagUrl.$val?>" title="<?php echo $val; ?>" name="<?php echo $val; ?>" style="padding:0px 3px 0px 3px;"><?php echo $val; ?> </a>
<p title="<?php echo $val; ?>" name="<?php echo $val; ?>" style="padding:0px 3px 0px 3px;"><?php echo $val; ?> </p><span style="padding:0px 2px 0px 2px;"><?php echo $this->__('(Actor)') ?></span>
<?php endforeach; ?>
<?php endif; ?>

<?php } ?>

for more info visit mage-people