4

Currently I have a Magento site which uses Layered Navigation. The client wants to be able to control the products displayed on the parent category AND have layered navigation enabled, thus turning off "Is Anchor" isn't an immediate solution.

Any idea how I can control the product list while also keeping the layered navigation provided by Is Anchor enabled?

  • Would hiding the product list entirely be an acceptable solution? Or are you looking to manage which subcats show up, specifically. – philwinkle Jul 26 '13 at 21:55
  • the client is looking to manage the subcategories as well as have layered navigation and control the parent category's products on display – Gerry Jul 27 '13 at 17:46
  • you could create a CMS block that displays the subcategories visually, displaying (for example) the image of the first item in each subcategory above its name. You then click on that image to see the full category. I don't see the point in displaying certain items in the parent category unless maybe if the store was very small. – Buttle Butkus Nov 19 '13 at 6:52
5

Create a category attribute. That's beyond the scope of this answer - here are some links to help you create one in an upgrade script:

Let's call your new attribute displaySubcategory... You'll want to make sure that your newly created attribute is of type boolean and defaults to true.

You can now edit whether your categories display or not from within the Admin > Catalog > Manage Categories. Each category should have a dropdown now that allows you to show or hide it.


Showing/hiding in layered nav:

From within /app/design/frontend/[yourpackage]/[yourtheme]/template/catalog/navigation/left.phtml you can add the new displaySubcategory alongside the isActive display condition:

<dl id="narrow-by-list2">
    <dt><?php echo $this->__('Category') ?></dt>
    <dd>
        <ol>
        <?php foreach ($_categories as $_category): ?>

            <?php if($_category->getDisplaySubcategory() && $_category->getIsActive()): ?>
            <li>
                <a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>><?php echo $this->htmlEscape($_category->getName()) ?></a> (<?php echo $_category->getProductCount() ?>)
            </li>
           <?php endif; ?> 

        <?php endforeach ?>
        </ol>
    </dd>
</dl>
3

It's complicated to do, but the best way to go about this is to modify the behavior of the category/product association index so that the products from child categories are not associated with the parents regardless of the is anchor setting.

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.