0

I've been working on having a two sets of layered navigation to make it easier to navigate my website. I have successfully added categories and manufacturers as a tab in the center. When I enabled price (or any other attribute) to be used in the left hand layered navigation, it became visible in the center. (See picture bellow)

dual navigation

The code for the center navigation:

<?php if($this->canShowBlock()): ?>
<div class="block-content">

    <?php if($this->canShowOptions()): ?>
            <?php $_filters = $this->getFilters() ?>
            <ul id="tabs">

            <?php $counterOne =0; ?>
            <?php $counterTwo =0; ?>
            <?php foreach ($_filters as $_filter): ?>
            <?php $counterOne++; ?>
            <?php if($_filter->getItemsCount()): ?>
             <li><a href="#" title="tab<?php echo $counterOne; ?>"><?php echo $this->__($_filter->getName()) ?></a></li>


            <?php endif; ?>
            <?php endforeach; ?>
            </ul>
            <div id="content"> 
             <?php foreach ($_filters as $_filter): ?>
             <?php $counterTwo++; ?>
            <?php if($_filter->getItemsCount()): ?>
                <div id="tab<?php echo $counterTwo; ?>"><?php echo $_filter->getHtml() ?></div>
            <?php endif; ?>
            <?php endforeach; ?>
       </div>
        <script type="text/javascript">decorateDataList('narrow-by-list')</script>
    <?php endif; ?>
</div>

How can I implement a filter in the above so that only the Category and Manufacturer will appear in the center layered navigation?

EDIT:

When I add:

<?php if($_filter->getName() == 'Category' || $_filter->getName() == 'Manufacturer' ): ?>

Directly bellow the first

<?php foreach ($_filters as $_filter): ?>

It works, however when I click on the Manufacturer under the manufacturer tab I receive a You cannot define a correlation name 'manufacturer_idx' more than once

Any thoughts?

EDIT What I am looking to achieve is to have Category and Manufacturer in the center while all other filterable attributes appear on the left. Is this possible?

  • Hi sr_magento, did you manage to find a fitting solution to the issue? – Sander Mangel Mar 31 '14 at 18:28
  • Hi Sander, not yet; I moved onto other projects and will circle back soon :), I really appreciate the follow up. SR – SR_Magento Mar 31 '14 at 18:29
3
+50

You will only be able to do this hardcoded.

So filtering out the manufacturer and category on the left side and creating a custom PHTML file that generates links/dropdowns for the manufacturer and category in the center.

so in app/design/frontend/[template]/[package]/template/catalog/layer/view.phtml around line 49 edit

<?php if($_filter->getItemsCount() && ($_filter->getName()!='manufacturer' || $_filter->getName()!='categories')): ?>
   <dt><?php echo $this->__($_filter->getName()) ?></dt>
   <dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>

Would eliminate manufacturer and categories from the list. Optionally try to use getCode, I think that would return the attribute_code instead of the name.

For your center layered navigation create a new PHTML file and add it to the layout

<reference name="content">
   <block type="core/template" name="center_layered_nav" template="catalog/layer/center.phtml"/>
</reference>

and in the file catalog/layer/center.phtml something like this

<form method="GET" id="center_layered">
<select name="manufacturer" onchange="document.getElementById('center_layered').submit();">
<?php 
$attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'manufacturer');

$options = $attribute->getSource()->getAllOptions(false);
foreach ($options as $option)
{
   echo '<option value="'.$option['value'].'">'.$option['label'].'</option>';
}
?>
</select>
</form>

when a user selects a manufacturer it should add manufacturer to the layered navigation URL. Manufacturer does have to be a filterable attribute tho.

This is highly untested code so may need a tweak or two but it's basically what you need. And I'm in no way pretending this is best practice but as far as I know it's the only way to do it.

  • Is there anyway to salvage the code I provided? It works it's just if I enable more than categories and manufacturers as filterable attributes, they appear in the center. IE: Like in the example provided. If I disable price as a filterable attribute then it only shows what I want, however it also gets disabled on the left navigation. Is there a way to specify only the two attributes that I want for the center and ignore the rest? – SR_Magento Mar 24 '14 at 16:38
  • The only way I know is the code I provided iin my answer. Any other way I'm afraid I can't help you with – Sander Mangel Mar 24 '14 at 16:47
  • Okay I'll play with your code again. Thanks Sander! SR – SR_Magento Mar 24 '14 at 16:52
  • @sr_magento Did you manage to resolve the issue? – Sander Mangel Mar 26 '14 at 21:56
  • Unfortunately no, I'll report back tomorrow. Thanks for checking. SR – SR_Magento Mar 26 '14 at 23:09

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.