5

I am developing a magento site where there is a left sidebar called "shop by category" by default in magento theme. I have created a category and there are some subcategories under parent category. When I go to parent category, it shows list of products as well as left sidebar with subcategories. But when I select subcategories, it shows list of products but left sidebar is missing. Is there any way to rectify it from admin or code level.

  • this is the default behaviour of magento. It will show categories in layered navigation section only if the viewing current categories has child categories and the viewing category is set with yes for the field is anchor. – Rajeev K Tomy Dec 11 '14 at 5:45
  • thanks to reply, I have not set "yes" for is anchor option for parent category too and it is listing "shop by category" and when I choose "yes" for is anchor option it does not show "shop by category" listing. – Arshad Hussain Dec 11 '14 at 5:54
15

Layout wise, magento distinguishes categories as default categories and layered categories. Magento uses is anchor option in order to make this categorization. If is anchor is set to yes, then that category would be layered category and if it is set tono, then that category will treat as a default catetgory.

What happens when we set the property is anchor to yes ?

Then the category will become a layered category. A category which holds layered navigation section along with it. Layered navigation will hold product attribute list which we set to include in layered in layered navigation so that we can filter products in a particular category using those product attriubte. color attribute is an example.

Another important thing about layered category - it will display all products not only from the selected category, but from its subcategories.

In this case, magento will process a unique layout handle catalog_category_layered.

What happens when we set the proeprty is anchor to no ?

Now these categories become default categories. Categories which will not show layered navigation section. So product attribute filtering is not possible for this type of categories.

Also a default category only show products which are assigned with that category itself. There is no possibility that it will show products that comes under its child categories.

In this case, Magento will process a unique layout handle catalog_category_default.

What is the problem here ?

You set all of your categories to default, coz is anchor property of all categories is set to no in your case.

There is very interesting point that I need to share with you in this case. If you take Magento's default theme (base/default), you can see that, layout handle for default categories catalog_category_default actually defines a left section. It looks like this.

File : app/design/frontend/base/default/layout/catalog.xml

<catalog_category_default translate="label">
    <label>Catalog Category (Non-Anchor)</label>
    <reference name="left">
        <block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
    </reference>
   ...
 </catalog_category_default>

This means it uses the block of type catalog/navigation in the left section. This block is actually responsible for the left content that you are viewing in a default category.

If you check inside catalog_category_layered, it uses another block of type catalog/layer_view to show the left section. So this block is obviously used to show the layered navigation section.

So the question is what is catalog/navigation block does for default categories ?

To answer the question, please have a look on the template file which is set with this block

 app/design/frontend/base/default/catalog/navigation/left.phtml

You will find this line there.

 <?php if (!Mage::registry('current_category')) return ?>
 <?php $_categories = $this->getCurrentChildCategories() ?>

It is clear that it collects all of its child categories and show as a link to filter. This means

category filtering is always available in every category irrespective of the value set to the field is anchor

So if you can see categories for a parent category and it seems empty for a child category, then that means the child category that you are describing actually does not hold any other child categories. At least this is the default case.

If the child category that you are referencing actually holds other child categories, then I am sure that some customization on the default behaviour is took place and you need to trace it out !!

1
  1. Go to the Magento backend.Click on the Catalog > Manage Categories.
  2. Click on the subcategory which is not showing the left navigation. then click on the "Display Settings".
  3. Under Is Anchor select Yes and save.
  4. Clear the cache and check

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.