문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top