I am showing the manufacturer attribute in catalog_product_view page on product/view.phtml using Code 1 (see below). I successfully included a list of all manufacturer attributes from Code 2.

  1. How to show the result of Code 1 with href link as in Code 2, which should redirect to advanced search result and show a list of all products for that selected manufacturer?


  2. How to restrict the results of Code 2 as in Code 1 (Instead of showing all results for manufacturer make it to show only one value as in Code 1)

Code 1

<?php if( $_product->getAttributeText('manufacturer') ): ?>
    <p class="manufacturer">Brand:<br/><?php echo $_product->getAttributeText('manufacturer')?></p>
 <?php endif; ?>

Example Output of Code 1:


Code 2

    $product = Mage::getModel('catalog/product');  
     $attributes = Mage::getResourceModel('eav/entity_attribute_collection')  
                   ->addFieldToFilter('attribute_code', 'manufacturer');  
     $attribute = $attributes->getFirstItem()->setEntity($product->getResource());  
     $manufacturers = $attribute->getSource()->getAllOptions(false);  
<ul id="manufacturer_list">    
      <?php foreach ($manufacturers as $manufacturer): ?>  
      <li><a href="<?php echo Mage::getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=<?php echo $manufacturer['value'] ?>"><?php echo $_product->getAttributeText('manufacturer')?></a></li>  
       <?php endforeach; ?>  

Example Output of Code 2:

<a href="[]=14">Nike</a>,<a href="[]=11">Reebok</a>,<a href="[]=18">Adidas</a>,<a href="[]=17">Etc</a>


I want it like this:

Required Output:

<a href="[]=14">Nike</a>


Like in Amazon:


Am using 1.9.2 Rwd theme,Any help would be appreciated..!

2 Answers 2


You were almost there. This combination of your codes should to the trick:

<?php if( $_product->getAttributeText('manufacturer') ): ?>
    <p class="manufacturer">
        <a href="<?php echo Mage::getUrl('catalogsearch/advanced/result', [
            '_query' => ['manufacturer' => $_product->getData('manufacturer')]
        ]) ?>">
            <?php echo $_product->getAttributeText('manufacturer')?>
<?php endif; ?>

Note that I used the standard Magento way to construct URLs instead of concatenating base URL, path and query parameters as you did. The result is the same.

What's important is that $product->getData('manufacturer') returns the internal value that you need for the link and $product->getAttributeText('manufacturer') returns the localized frontend value.


you can use http_build_query();

$data = array('foo', 'bar', 'baz', 'boom', 'cow' => 'milk', 'php' =>'hypertext processor');

echo http_build_query($data) . "\n";

Output :
see more

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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