0

I want to display the links layered navigation which shows all products that have a certain attribute value.

For example, I have 3 categories with products in them. Each category can have different manufacturers for products. I want the footer to have a link for manufacturer which shows all products with that manufacturer regardless of which category they are in. I want to have multiple sections in the footer where each section will do this for a different custom attribute.

0

This may not be a layered navigation solution but it will do what you're describing. You'll want to put this code in an extension and pull it in as a block in your footer instead of just placing it in footer.phtml.

$attribute_code = "gender"; // your attribute code
$attribute_value = 93;    // id of the attribute value
$product_limit = 3;        // number of products to return

$product_collection = Mage::getModel('catalog/product')->getCollection()
              ->addAttributeToSelect('*')  // return all attributes. you can add additional lines to pull specific attributes to be more efficient
              ->addFieldToFilter(array(array('attribute'=>$attribute_code,'eq'=>$attribute_value))) 
              ->setPageSize($product_limit) // number of products to return
              ->setCurPage(1);

foreach ($product_collection as $product) {

    $product_name = $product->getName();
    // you can pull all the attributes you want to display here

    echo '<div class="product">'.$product_name.'</div>';
    // create your product layout and display the data here
}
| improve this answer | |
  • I only want the link for an attribute in the footer, not the product name. I think it probably requires a bit of logic that needs to be put into an extension. The Amasty Improved Layered navigation extension might accomplish what I want. I just wanted a way to do it without a full extension. – Chris McKnight Feb 10 '15 at 22:33
  • You can put whichever attribute you want. $product->getName() was just an example. – seanbreeden Feb 11 '15 at 0:13
  • @ChrisMcKnight I haven't really dug into this; but I have ripped the 1.9 topnav apart and I would suggest more closely mimicking its behavior (if that is indeed what you're building on) by using varien_data_trees to simplify the development/rendering process - docs.magentocommerce.com/Varien/Varien_Data/… Also- loading additional product models on every page is likely going to add a noticeable amount of load time to your whole site. You may want to look into using Elasticsearch to do this. LMK if you want a more detailed answer/example and I can whip one up. – Reid Blomquist Jun 10 '15 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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